它只读取收件箱中的新邮件,而我想阅读所有邮件。如何实现?
Folder folderInbox = store.getFolder("INBOX");
folderInbox.open(Folder.READ_ONLY)
Message[] arrayMessages = folderInbox.getMessages();
您能否尝试Message[] messages = inbox.getMessages(startMessage, endMessage);
而不是Message[] arrayMessages = folderInbox.getMessages();
这里的开始消息和结束消息是整数值。从这里取的一个很好的例子 - 在此处输入链接描述
Folder inbox = store.getFolder("inbox");
inbox.open(Folder.READ_WRITE); // Folder.READ_ONLY
int messageCount = inbox.getMessageCount();
System.out.println("Total Messages" + messageCount);
int startMessage = messageCount - 5;
int endMessage = messageCount;
if (messageCount < 5) {
startMessage = 0;
}
Message[] messages = inbox.getMessages(startMessage, endMessage);