java 邮件 api, imap 文件夹 UIDNEXT 始终为 -1
java mail api, imap folder UIDNEXT is always -1
你好,我使用 java api 从 imap 文件夹中获取邮件,我可以获得 headers 等,但 UIDNEXT 始终为 -1,但下一封邮件的值类似于100.
所有邮件服务器都不支持 UIDNEXT 吗?
UIDFolder ufolder = (UIDFolder) folder;
folder.open(Folder.READ_WRITE);
IMAPFolder iFolder = (IMAPFolder) folder;
int totalMessages = iFolder.getMessageCount();
int unreadMessages = iFolder.getUnreadMessageCount();
int newMessages = iFolder.getNewMessageCount();
int deletedMessages = iFolder.getDeletedMessageCount();
boolean bNew = iFolder.hasNewMessages();
long uidnext = iFolder.getUIDNext();
除了 UIDNEXT,我得到了其他参数的正确值,但 uidnext 总是返回 -1?
查看 https://javamail.java.net/nonav/docs/api/com/sun/mail/imap/IMAPFolder.html#getUIDNext() 的文档,这取决于您的服务器:
Servers implementing RFC2060 likely won't return this value when a folder is opened. Servers implementing RFC3501 should return this value when a folder is opened.
尝试在调用 getUIDNext() 之前关闭文件夹。
你好,我使用 java api 从 imap 文件夹中获取邮件,我可以获得 headers 等,但 UIDNEXT 始终为 -1,但下一封邮件的值类似于100.
所有邮件服务器都不支持 UIDNEXT 吗?
UIDFolder ufolder = (UIDFolder) folder;
folder.open(Folder.READ_WRITE);
IMAPFolder iFolder = (IMAPFolder) folder;
int totalMessages = iFolder.getMessageCount();
int unreadMessages = iFolder.getUnreadMessageCount();
int newMessages = iFolder.getNewMessageCount();
int deletedMessages = iFolder.getDeletedMessageCount();
boolean bNew = iFolder.hasNewMessages();
long uidnext = iFolder.getUIDNext();
除了 UIDNEXT,我得到了其他参数的正确值,但 uidnext 总是返回 -1?
查看 https://javamail.java.net/nonav/docs/api/com/sun/mail/imap/IMAPFolder.html#getUIDNext() 的文档,这取决于您的服务器:
Servers implementing RFC2060 likely won't return this value when a folder is opened. Servers implementing RFC3501 should return this value when a folder is opened.
尝试在调用 getUIDNext() 之前关闭文件夹。