Android™
Android™
Get and Set the Email Subject
See more Email Object Examples
Demonstrates the Chilkat Email.Subject property, which reads or writes the MIME Subject header. When the subject contains non-ASCII characters, Chilkat performs the required MIME header encoding automatically. This example sets a subject and reads it back.
Background: MIME headers were originally restricted to plain ASCII, which is a problem for subjects containing accented letters, emoji, or non-Latin scripts. The solution (RFC 2047) is "encoded-words," where such text is wrapped like
=?utf-8?B?...?= so it travels safely through mail systems. You work with the Subject property as ordinary readable text — Chilkat handles the encoding on the way out and the decoding on the way in.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 getting and setting the Email.Subject property, which reads or writes
// the MIME Subject header. Chilkat performs the required MIME header encoding when the
// subject contains non-ASCII characters.
CkEmail email = new CkEmail();
email.put_Subject("Meeting agenda for Monday");
Log.i(TAG, "Subject = " + email.subject());
}
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."
}
}