((Message)message).setFlag(Flags.Flag.DELETED, true); ... folder.close(true)
This should work for common ldap accounts, but it doesn't work properly in gmail. It just removes the message from the "folder", which is actually mapped as a gmail label. The message will remain under "All messages". Next, I found that I should move the message to the trash folder:
Folder skypeFolder = mailStore.getFolder("Skype-Chats"); Folder trash = mailStore.getFolder("[Gmail]/Trash"); Message[] messagesToRemove = new Message[]{messageToRemove}; skypeFolder.copyMessages(messagesToRemove, trash); // and just to make sure mimeMessage.setFlag(Flags.Flag.DELETED, true);
Well, it did work... kinda. A problem still remained: if you send a new message with the same sender and subject, the "deleted" message gets resurrected.
I couldn't figure out how to remove it permanently. I got around the problem changing the subject, when need...
No comments:
Post a Comment