使用Java Mail API保存草稿消息吗? [英] Save Draft Message Using Java Mail API?

查看:333
本文介绍了使用Java Mail API保存草稿消息吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前我正在按照以下步骤进行操作

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.

推荐答案

正如上面其他建议一样,您需要将消息草稿存储在其他文件夹中.您可以选择该文件夹的名称.如果您仅使用Gmail,并且希望与Gmail的操作保持一致,则将其保存在Gmail使用的文件夹中("[Gmail]/草稿"?).发送邮件时,请记住将其从文件夹中删除.

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.

这篇关于使用Java Mail API保存草稿消息吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆