我要从Office的Outlook中配置的特定文件夹和组的特定邮件ID中下载附件 我收到此错误
我尝试将字符串从INBOX更改为其他文件夹,附件将保存在本地计算机上的文件夹中
Store store = session.getStore("pop3");
store.connect(userName, password);
Folder folderInbox = store.getFolder("payslip");
folderInbox.open(Folder.READ_ONLY);
Message[] arrayMessages = folderInbox.getMessages();
我遇到以下错误
Could not connect to the message store
javax.mail.FolderNotFoundException: folder is not INBOX
at com.sun.mail.pop3.POP3Folder.open(POP3Folder.java:192)
at com.jcp.automation.EmailAttachmentReceiver.downloadEmailAttachments(EmailAttachmentReceiver.java:68)
at com.jcp.automation.EmailAttachmentReceiver.main(EmailAttachmentReceiver.java:150)
log4j:WARN No appenders could be found for logger (com.jcp.automation.EmailAttachmentReceiver).
log4j:WARN Please initialize the log4j system properly.
答案 0 :(得分:1)
我用imap代替了pop3,这是代码
properties.setProperty("mail.store.protocol", "imaps");
properties.setProperty("mail.imaps.port", "993");
Session session = Session.getDefaultInstance(properties);
try {
session = Session.getDefaultInstance(properties, null);
javax.mail.Store store = session.getStore("imaps");
store.connect("outlook.office365.com", "xyz", "xyz");
Folder folderInbox = store.getFolder("james");
folderInbox.open(Folder.READ_ONLY);