Reputation: 2297
Currently im doing as following,
@Override
public void saveDraftMessage(MimeMessage draftMessage) throws MessagingException
{
Folder draftsMailBoxFolder = imapsStore.getFolder("inbox");//[Gmail]/Drafts
draftsMailBoxFolder.open(Folder.READ_WRITE);
draftMessage.setFlag(Flag.DRAFT, true);
MimeMessage draftMessages[] = {draftMessage};
draftsMailBoxFolder.appendMessages(draftMessages);
}
It works but , as you could see message is being appended to "inbox" folder without complain from server end !
Is there any kind of validation or an alternative method to ensure that message is saved as Draft only at appropriate place.
Upvotes: 4
Views: 4788
Reputation: 29971
As others have suggested above, you need to store your draft messages in a different folder. You can choose the name of that folder. If you're only using Gmail and you want to be consistent with what Gmail is doing, saving it in the folder Gmail uses ("[Gmail]/Drafts"?) would make sense. Remember to delete the message from the folder when you send it.
Upvotes: 3