Android™
Android™
Add a To Recipient to an Email
See more Email Object Examples
Demonstrates the Chilkat Email.AddTo method, which adds a single direct (To) recipient. The first argument is the friendly display name and the second is the email address. This example adds one To recipient and prints the resulting count.
Background: The
To recipients are a message's primary audience — the people it is directly addressed to. Each recipient is stored as a display name plus an email address, which together render in the header as Bob <bob@example.com>. Call AddTo once per recipient, or use AddMultipleTo to add several from a single comma-separated string.Chilkat Android™ Downloads
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;
import android.app.Activity;
import com.chilkatsoft.*;
import android.widget.TextView;
import android.os.Bundle;
public class SimpleActivity extends Activity {
private static final String TAG = "Chilkat";
// Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Demonstrates the AddTo method, which adds a single direct (To) recipient.
// The 1st argument is the friendly (display) name, and the 2nd is the email address.
CkEmail email = new CkEmail();
email.put_Subject("AddTo example");
email.put_From("alice@example.com");
email.AddTo("Bob","bob@example.com");
Log.i(TAG, "NumTo = " + String.valueOf(email.get_NumTo()));
}
static {
System.loadLibrary("chilkat");
// Note: If the incorrect library name is passed to System.loadLibrary,
// then you will see the following error message at application startup:
//"The application <your-application-name> has stopped unexpectedly. Please try again."
}
}