Save Draft Message Using Java Mail API?

末鹿安然 提交于 2020-01-05 08:26:26

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/11524716/save-draft-message-using-java-mail-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!