public static void main(String[] args) throws MessagingException, IOException {
String imapserver = "******"; // 邮件服务器
String user = "*****";
String pwd = "****"; // 根据自已的密码修改
// 获取默认会话
Properties prop = System.getProperties();
prop.put("mail.imap.host",imapserver);
// prop.put("mail.imap.auth.plain.disable","true");
Session mailsession=Session.getInstance(prop,null);
mailsession.setDebug(false); //是否启用debug模式
IMAPFolder folder= null;
IMAPFolder tobedeterminedFolder=null;
IMAPStore store=null;
int total= 0;
try{
store=(IMAPStore)mailsession.getStore("imap"); // 使用imap会话机制,连接服务器
store.connect(imapserver,user,pwd);
folder=(IMAPFolder)store.getFolder("INBOX"); //收件箱
folder.open(Folder.READ_WRITE);
JavaMail 移动邮件到其他目录
最新推荐文章于 2024-02-27 16:18:04 发布
本文详细介绍了使用JavaMail API如何有效地将收件箱中的邮件移动到不同的文件夹,包括必要的配置、API调用以及可能出现的问题和解决方案。

最低0.47元/天 解锁文章
3114

被折叠的 条评论
为什么被折叠?



