Sample code for 30+ languages & platforms
CkJava Requires Chilkat v11.0.0+

Read individual messages in a MIME digest

See more Email Object Examples

Use a saved multipart/digest message. NumDigests and GetDigestEmail expose each enclosed message as an Email object. Inspect its own sender and subject instead of assuming all entries share the wrapper’s metadata.

Chilkat CkJava Downloads

CkJava
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    boolean success = false;

    //  Assumes Chilkat is unlocked. See Global Unlock Sample.

    CkEmail email = new CkEmail();
    success = email.LoadEml("digest.eml");
    if (success != true) {
        System.out.println(email.lastErrorText());
        return;
        }

    System.out.println("Digest entries: " + email.get_NumDigests());
    CkEmail item = new CkEmail();
    int i = 0;
    while ((i < email.get_NumDigests())) {
        success = email.GetDigestEmail(i,item);
        if (success != true) {
            System.out.println(email.lastErrorText());
            return;
            }

        System.out.println(i + "  " + item.fromAddress() + "  " + item.subject());
        i = i+1;
        }
  }
}