I have been using java mail (POP3 client & IMAP) to automate Gmail operation. One of the operation is to delete mail and I use following code -
public void deleteInboxMasseges() throws IOException, MessagingException
{
store = getConnection(EMAIL_USERNAME, EMAIL_PASSWORD);
if (store != null)
{
int inboxMassegeCount = inbox.getMessageCount();
Message[] messages = inbox.getMessages();
for (int i = 0; i < inboxMassegeCount; i++)
{
messages[i].setFlag(Flags.Flag.DELETED, true);
}
inbox.expunge();
}
}
The Mail is deleted from "Inbox" but its available in "All Mail" only not in "Trash" folder. I want to delete it permanently. Is there any straight way to delete mail permanently instead of deleting mail from "inbox"?