Java
Chilkat2 Java
IMAP Session Logging
Demonstrates how to use session logging with IMAP.Chilkat Java Downloads
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Imap;
public class ChilkatExample {
public static void main(String[] args) {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Imap imap = new Imap();
// Set the KeepSessionLog property to enable IMAP session logging
imap.setKeepSessionLog(true);
// Connect to an IMAP server.
// Use TLS
imap.setSsl(true);
imap.setPort(993);
try {
imap.connect("imap.example.com");
// Login
imap.login("mylogin", "mypassword");
// Select an IMAP mailbox
imap.selectMailbox("Inbox");
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
// We're not really doing anything in this example
// other than to show how to examine the IMAP component's session log...
// Disconnect from the IMAP server.
imap.disconnect();
// Display the session log...
System.out.println(imap.getSessionLog());
}
}