Deleting all email messages |
Upon disconnecting from a POP3 server you can optionally delete any messages retrieved from the account mailbox during your session by invoking the Pop#setDelete method with a true argument prior to retrieving any messages from the mailbox.
Example
// establish connection pop.connect();
// mark messages retrieved for deletion upon logout pop.setDelete(true);
// get messages in mailbox Enumeration e = pop.getMessages();
// loop thru all messages in mailbox marking each for deletion upon retrieval while(e.hasMoreElements()) { EmailMessage message = (EmailMessage)e.nextElement(); }
// delete messages marked for deletion and logout pop.disconnect(); |