Android™
Android™
Convert an Email to Chilkat XML
See more Email Object Examples
Demonstrates the Chilkat Email.GetXml method, which converts the email object to an XML document in memory. The XML is Chilkat's own email-object representation — it is not MIME and not a standardized interchange format. This example builds a message and prints its XML.
Background: This XML form is a Chilkat-specific way to serialize an
Email object that can be reloaded with LoadXml / LoadXmlString. Because it is not standard MIME, other mail software cannot read it. In practice the standard .eml format (GetMime / SaveEml) is preferred even within Chilkat-based software: .eml is interoperable and also preserves Chilkat's CKX- metadata headers (which are always removed before an email is sent), so the XML format offers no metadata advantage.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 GetXml method, which converts the email object to an XML document in
// memory. The XML is Chilkat's email-object representation (not MIME and not a
// standardized interchange format).
CkEmail email = new CkEmail();
email.put_Subject("GetXml example");
email.put_From("alice@example.com");
email.AddTo("Bob","bob@example.com");
email.put_Body("Hello!");
// Convert the email to Chilkat's XML representation.
String xmlStr = email.getXml();
Log.i(TAG, xmlStr);
}
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."
}
}