Android™
Android™
Load an Email from a Chilkat XML File
See more Email Object Examples
Demonstrates the Chilkat Email.LoadXml method, which loads an email from a Chilkat XML email file (as produced by SaveXml). On success, the loaded message replaces the entire current email, including recipients, headers, bodies, related items, and attachments. This example loads the XML and reads its subject and from.
Background: Chilkat's XML email format is one way to persist a message — an alternative to the standard
.eml (MIME) format. It is worth knowing that .eml also preserves Chilkat-specific metadata: header fields whose names begin with CKX- are stored in the saved MIME and restored on load, and are simply always removed before an email is actually sent. Because .eml is the universal, interoperable format and captures the same metadata, Chilkat recommends using .eml (LoadEml / SaveEml) over the XML format — even within Chilkat-based software.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;
// Demonstrates the LoadXml method, which loads an email from a Chilkat XML email file.
// On success, the loaded message replaces the entire current email.
CkEmail email = new CkEmail();
success = email.LoadXml("qa_data/xml/email.xml");
if (success == false) {
Log.i(TAG, email.lastErrorText());
return true;
}
Log.i(TAG, "Subject: " + email.subject());
Log.i(TAG, "From: " + email.ck_from());
// Note: The path "qa_data/..." is a relative local filesystem path,
// relative to the current working directory of the running application.
}
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."
}
}