Java
Java
Transition from Imap.FetchSingleHeader to Imap.FetchEmail
Provides instructions for replacing deprecated FetchSingleHeader method calls with FetchEmail.Chilkat Java Downloads
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;
CkImap imap = new CkImap();
// ...
// ...
// ------------------------------------------------------------------------
// The FetchSingleHeader method is deprecated:
CkEmail emailObj = imap.FetchSingleHeader(1,false);
if (imap.get_LastMethodSuccess() == false) {
System.out.println(imap.lastErrorText());
return;
}
// ...
// ...
// ------------------------------------------------------------------------
// Do the equivalent using FetchEmail.
// 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 = imap.FetchEmail(headerOnly,1,false,emailOut);
if (success == false) {
System.out.println(imap.lastErrorText());
return;
}
}
}