I have been using java mail to automate Gmail operations. One of the operation is to delete mail and I use following for it -
message.setFlag(Flags.Flag.DELETED, true);
but doing so only pushes my mails to spam folder.
I am wondering if there is a straight way to delete mail permanently instead of deleting mail from "inbox" first and then searching mails in "spam " folder and deleting them.
Scroll to Trash. Check the box next to messages you want to permanently delete. Then click Delete forever.
At the top of your inbox, above the message list, select the check box. Above the message list, select Delete. All the email in your inbox will be moved to the Deleted Items folder. To permanently delete the messages, right-click the Deleted Items folder and select Delete all.
IMAP accounts provide several options to delete messages that aren't available in POP accounts. Tools -> Account Settings -> Account Name -> Server Settings -> "When I delete a message" has choices for "Move it to the Trash folder", "Mark it as deleted" and "Remove it immediately".
Deleting all your emails in Gmail is simple: open Gmail, select the inbox tab you want to clear out (Primary, Promotions, etc.) and click the small empty box in the top left corner, just above the Compose button. This will select everything on the current page of your inbox.
According to http://mail.google.com/support/bin/answer.py?answer=78755:
If you want to delete a message from all folders, move it to the [Gmail]/Trash folder.
If you delete a message from [Gmail]/Spam or [Gmail]/Trash, it will be deleted permanently.
However, that page doesn't give any indication that your approach would move mail to the spam folder; and it implies that you should see a folder named [Gmail]/Spam
; so maybe it doesn't apply to your situation, somehow? I think you'll just have to try its approach, and see whether it works for you!
You told that you are trying
message.setFlag(Flags.Flag.DELETED, true);
did you tried
folder.close(true);
this will expunge all messages with DELETED flags.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With