Sample code for 30+ languages & platforms
Java

Transition from MailMan.FetchSingleHeader to MailMan.FetchOne

Provides instructions for replacing deprecated FetchSingleHeader method calls with FetchOne.

Chilkat Java Downloads

Java
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;

    CkMailMan mailman = new CkMailMan();

    //  ...
    //  ...

    int numBodyLines = 5;
    int msgnum = 1;

    //  ------------------------------------------------------------------------
    //  The FetchSingleHeader method is deprecated:

    CkEmail emailObj = mailman.FetchSingleHeader(numBodyLines,msgnum);
    if (mailman.get_LastMethodSuccess() == false) {
        System.out.println(mailman.lastErrorText());
        return;
        }

    //  ...
    //  ...

    //  ------------------------------------------------------------------------
    //  Do the equivalent using FetchOne.
    //  Your application creates a new, empty Email object which is passed 
    //  in the last argument and filled upon success.

    boolean headerOnly = true;

    CkEmail emailOut = new CkEmail();
    success = mailman.FetchOne(headerOnly,numBodyLines,msgnum,emailOut);
    if (success == false) {
        System.out.println(mailman.lastErrorText());
        return;
        }
  }
}