Android™
Android™
MIME Multipart Boundary and Preamble Properties
See more MIME Examples
Demonstrates the Boundary property, which gets or sets the raw boundary token of a multipart entity (without surrounding quotation marks), and UseMmDescription, which controls whether the conventional preamble text is emitted when serializing a multipart entity.
Background. A multipart boundary separates the constituent parts. Chilkat quotes the token automatically in the header when required. The preamble is ignored by MIME-aware readers and is off by default.
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;
CkMime mime = new CkMime();
// Create a multipart/mixed entity.
success = mime.NewMultipartMixed();
if (success == false) {
Log.i(TAG, mime.lastErrorText());
return;
}
// Boundary is the raw boundary token, without surrounding quotation marks. Chilkat quotes it
// automatically in the serialized header when required.
mime.put_Boundary("example-boundary");
// UseMmDescription controls whether the conventional preamble text
// "This is a multi-part message in MIME format." is emitted. The default is false.
mime.put_UseMmDescription(true);
// Add a simple part so the multipart has content.
CkMime part = new CkMime();
success = part.SetBodyFromPlainText("First part.");
if (success == false) {
Log.i(TAG, part.lastErrorText());
return;
}
success = mime.AppendPart(part);
if (success == false) {
Log.i(TAG, mime.lastErrorText());
return;
}
Log.i(TAG, "Boundary = " + mime.boundary());
String mimeStr = mime.getMime();
if (mime.get_LastMethodSuccess() == false) {
Log.i(TAG, mime.lastErrorText());
return;
}
Log.i(TAG, mimeStr);
}
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."
}
}