Android™
Android™
Fetch a POP3 Message's Raw MIME by UIDL
See more POP3 Examples
Demonstrates the Chilkat MailMan.FetchMimeBd method, which fetches an email from the POP3 server by UIDL and stores the raw MIME source bytes in a BinData. Chilkat clears the BinData before downloading. This example fetches one message's MIME into a BinData.
Background: Sometimes you want the message exactly as it arrived — the raw MIME bytes — rather than a parsed
Email object, for example to archive it verbatim as a .eml file, forward it untouched, or hash it. Fetching into a BinData preserves every byte precisely, without any parsing or re-encoding that could alter the original.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 MailMan.FetchMimeBd method, which fetches an email from the POP3 server
// by UIDL and stores the raw MIME source bytes in a BinData. Chilkat clears the BinData
// before downloading.
CkMailMan mailman = new CkMailMan();
// Configure the POP3 server connection.
mailman.put_MailHost("pop.example.com");
mailman.put_MailPort(995);
mailman.put_PopSsl(true);
mailman.put_PopUsername("user@example.com");
mailman.put_PopPassword("myPassword");
// Fetch the raw MIME of a specific message by UIDL into a BinData.
CkBinData bdMime = new CkBinData();
success = mailman.FetchMimeBd("0000000123abcdef",bdMime);
if (success == false) {
Log.i(TAG, mailman.lastErrorText());
return;
}
Log.i(TAG, "MIME size (bytes) = " + String.valueOf(bdMime.get_NumBytes()));
// Note: Explicitly connecting/authenticating is optional. Chilkat MailMan automatically
// connects and authenticates -- using the property settings above -- whenever a server
// operation requires it. Calling the explicit connect/authenticate methods can still be
// helpful to determine whether a failure occurs while connecting or while authenticating.
}
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."
}
}