Android™
Android™
Email Body - Plain Text and/or HTML
Any given email may have a plain-text body, an HTML body, or both. The Body property will return the HTML body by default (if it exists) otherwise it will return the plain-text body. There are methods for checking to see if an email has a particular body (HasPlainTextBody and HasHtmlBody) and there are methods for getting a specific body: GetHtmlBody, GetPlainTextBody.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);
boolean success = false;
CkEmail email = new CkEmail();
// Load an email from a .eml
success = email.LoadEml("something.eml");
if (success != true) {
Log.i(TAG, email.lastErrorText());
return;
}
// Display the default Body:
Log.i(TAG, email.body());
// If a plain-text body is present, display it:
boolean bText;
bText = email.HasPlainTextBody();
if (bText == true) {
Log.i(TAG, email.getPlainTextBody());
}
// If an HTML body is present, display the HTML source:
boolean bHtml;
bHtml = email.HasHtmlBody();
if (bHtml == true) {
Log.i(TAG, email.getHtmlBody());
}
}
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."
}
}