JavaMail中的Gmail邮件ID

时间:2016-08-17 21:27:42

标签: java gmail javamail

我正在尝试按照以下网站上显示的协议,了解如何在JavaMail上实施GmailMsgIdTerm。

https://javamail.java.net/nonav/docs/api/com/sun/mail/gimap/package-summary.html

但是,它会不断连接到正确的文件夹(例如[Gmail] /所有邮件),但无法根据作为GmailMsgId输入的Long值找到邮件。

我初始化一个名为foundMessages的消息[],然后运行:

   foundMessages = folder.search(new GmailMsgIdTerm(<long value>));

我知道,使用原始IMAP命令时,此Gmail邮件ID存在。我怎么能用JavaMail做到这一点?

调试输出如下,然后是自定义的Exception,告诉我Message数组包含0个项目。

DEBUG: getProvider() returning     javax.mail.Provider[STORE,gimaps,com.sun.mail.gimap.GmailSSLStore,Oracle]
DEBUG: mail.imap.fetchsize: 16384
DEBUG: mail.imap.statuscachetimeout: 1000
DEBUG: mail.imap.appendbuffersize: -1
DEBUG: mail.imap.minidletime: 10
DEBUG: enable SASL
DEBUG: SASL mechanisms allowed: XOAUTH2
DEBUG: trying to connect to host "imap.gmail.com", port 993, isSSL true
* OK Gimap ready for requests from 63.118.185.105 f7mb171257288yxb
A0 CAPABILITY
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH2 AUTH=PLAIN AUTH=PLAIN-CLIENTTOKEN         AUTH=OAUTHBEARER AUTH=XOAUTH
A0 OK Thats all she wrote! f7mb171257288yxb
DEBUG IMAP: AUTH: XOAUTH2
DEBUG IMAP: AUTH: PLAIN
DEBUG IMAP: AUTH: PLAIN-CLIENTTOKEN
DEBUG IMAP: AUTH: OAUTHBEARER
DEBUG IMAP: AUTH: XOAUTH
DEBUG: protocolConnect login, host=imap.gmail.com, user=<email-address>, password=<non-null>
DEBUG IMAP: SASL authentication command trace suppressed
IMAP SASL DEBUG: Mechanisms: XOAUTH2
IMAP SASL DEBUG: SASL client XOAUTH2
IMAP SASL DEBUG: challenge:  :
IMAP SASL DEBUG: callback length: 1
IMAP SASL DEBUG: callback 0:    javax.security.auth.callback.NameCallback@39529185
IMAP SASL DEBUG: response: user=<email-address>auth=Bearer   ya29.CjFCA9APp5RaEl1vCGOmxTAoltUxFTlzYQfHYxTEwpebMroDoAFIqw2zmrvSmnBqzKkw :
DEBUG IMAP: SASL authentication succeeded
A2 CAPABILITY
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS XXXXXXXXXXXXXXXX ENABLE MOVE XXXXXXXXX ESEARCH UTF8=ACCEPT LIST-EXTENDED LIST-STATUS APPENDLIMIT=35882577 LITERAL-
A2 OK Success
DEBUG: connection available -- size: 1
A3 EXAMINE Inbox
* FLAGS (\Answered \Flagged \Draft \Deleted \Seen $Forwarded $Junk     $NotJunk $NotPhishing $Phishing NotJunk)
* OK [PERMANENTFLAGS ()] Flags permitted.
* OK [UIDVALIDITY 633094064] UIDs valid.
* 970 EXISTS
* 0 RECENT
* OK [UIDNEXT 978] Predicted next UID.
* OK [HIGHESTMODSEQ 968042]
A3 OK [READ-ONLY] Inbox selected. (Success)      

0 个答案:

没有答案