I’ve written a Java-based standalone program (using JavaMail API) to read email messages from a POP3 server and it implements ConnectionListener to capture events like opening, closing and disconnecting. I’ve added debug statements by implementing the methods available in ConnectionListener interface as shown below:
@Override
public void opened(ConnectionEvent ce)
{
System.out.println("Connection opened successfully!");
}
@Override
public void disconnected(ConnectionEvent ce)
{
System.out.println("Connection disconnected successfully!");
}
@Override
public void closed(ConnectionEvent ce)
{
System.out.println("Connection closed successfully!");
}
As per JavaMail doc, these methods are invoked when a Store/Folder/Transport is opened, disconnected or closed. Am able to successfully connect, open, get messages and close, but its related events (open, disconnect, close) are not getting triggered and hence the debug statements are also not printed.
Any help in this regard are appreciated.
NOTE: I’m using JDK1.6.0 and JavaMail 1.4
Did you register the listener with the Store?