Android™
Android™
Set the Sender Email Address
See more Email Object Examples
Demonstrates the Chilkat Email.FromAddress property, which is the email address of the sender. Changing this property updates the address portion of the MIME From header while preserving the sender name when possible. This example sets the sender name and address separately, then reads back the combined From header.
Background: A
From header has two parts: the display name (e.g. John Smith) and the email address (e.g. john.smith@example.com). Only the address is used to actually route the message; the display name is cosmetic. Chilkat lets you manipulate each part independently through FromAddress and FromName, or the whole thing at once through From.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 Email.FromAddress property (the email address of the sender).
// Setting it updates the address portion of the From header while preserving
// the sender name when possible.
CkEmail email = new CkEmail();
email.put_FromName("John Smith");
email.put_FromAddress("john.smith@example.com");
Log.i(TAG, "FromAddress = " + email.fromAddress());
Log.i(TAG, "From = " + email.ck_from());
}
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."
}
}