我正在使用Jodd版本3.9,我想阅读一个outlook帐户(Microsoft Exchange)。]
int port = 993;
ImapSslServer imapServer = new ImapSslServer("mail.myhost.it", port, "authuser", "authpass");
imapServer.setProperty("mail.imap.connectiontimeout", "15000");
ReceiveMailSession session = imapServer.createSession();
session.open();
_log.info("total number of inbox emails : " + session.getMessageCount());
ReceivedEmail[] emails = session.receiveEmailAndMarkSeen(EmailFilter.filter().flag(Flags.Flag.SEEN, false));
但是我在以下行收到此错误:session.receiveEmailAndMarkSeen(...)
jodd.mail.MailException: Message parsing failed; <---
java.lang.NullPointerException
这是一个调试:
A8 FETCH 4 (BODYSTRUCTURE)
* 4 FETCH (BODYSTRUCTURE (("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 1401 35 NIL NIL NIL NIL) "mixed" ("boundary" "----=_Part_1029639_1159929762.1507643405808") NIL NIL))
[ERROR] 11 ott 04:57:31.467 PM [com.afterbit.jobs.EmailJob] (mGxTfT0) EXCEPTION session.receiveEmailAndMarkSeen : jodd.mail.MailException: Message parsing failed; <--- java.lang.NullPointerException
A9 CLOSE
A8 OK FETCH completed.
A9 OK CLOSE completed.
我不明白为什么...
[已解决] 我希望这有帮助...并节省时间(我花了很多天.Javamail和Apache CXF之间存在冲突。Apache CXF有一个内部文件geronimo-javamail_1.4_spec-1.7.1.jar。因此,如果您将邮件.jar(javamail)也添加到项目中并使用IMAP协议,则可能会产生如上所述的错误!