Android™
Android™
Send to a File-Based Distribution List
See more Email Object Examples
Demonstrates the Chilkat Email.FileDistList property. Set this property to send an email to a list of recipients stored in a plain-text file — one recipient per line, blank lines ignored, no comments. Setting it is equivalent to adding a CKX-FileDistList header field. When the email is sent, MailMan reads the file and delivers to each recipient. This example sets the distribution-list file and prints the MIME.
Background: MIME headers whose names start with
X- are non-standard, application-specific fields. Chilkat extends this idea with its own CKX- prefix: these fields let you attach instructions to an email object that Chilkat understands, but they are stripped before transmission so they never appear in the delivered message. They are preserved when you save/load the email as XML or MIME, making them handy for storing send-time metadata like a distribution list.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 Email.FileDistList property.
// Setting this property causes MailMan to send the email to a list of
// recipients stored in a plain-text file (one recipient per line).
// Setting it is equivalent to adding a CKX-FileDistList header field.
CkEmail email = new CkEmail();
email.put_Subject("Newsletter");
email.put_Body("Hello subscribers!");
email.put_From("news@example.com");
// The file contains one recipient email address per line.
email.put_FileDistList("qa_data/txt/recipients.txt");
Log.i(TAG, "FileDistList = " + email.fileDistList());
// The CKX-FileDistList header field is present in the saved MIME, but CKX-
// fields are never transmitted when the email is actually sent.
Log.i(TAG, email.getMime());
}
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."
}
}