Deleting a single email message |
Upon establishing a connection to an IMAP server you can mark an individual message for deletion from the mailbox by invoking the Imap#deleteMessage method with an argument of the message id to delete. Message id's are one (1) based with the first message in mailbox being 1, the second 2 etc. To delete any messages marked for deletion you must invoke the Imap#expunge method.
Example
// establish connection imap.connect();
// mark first message in mailbox for deletion imap.deleteMessage(1);
// delete any messages marked for deletion and disconnect imap.expunge(); imap.disconnect(); |