Retrieving new email messages |
Upon establishing a connection to an IMAP server you can retrieve any new email messages in the account mailbox by invoking the Imap#getNewMessages method. New messages are messages received since the last time the account was accessed. Any new messages found will be returned as a java.util.Enumeration of type com.jscape.inet.email.EmailMessage
Example
import com.jscape.inet.imap.*; import com.jscape.inet.email.*;
// establish connection imap.connect();
// get messages in mailbox Enumeration e = imap.getNewMessages();
// loop thru all messages in mailbox while(e.hasMoreElements()) { EmailMessage message = (EmailMessage)e.nextElement(); // print out subject System.out.println(message.getSubject()); }
See also
|