使用javamail查询收件箱,如何获得邮件的发送时间呢?请详细说明,谢谢

2024-11-29 09:50:54
推荐回答(2个)
回答1:

首先必须获取链接:
Properties props = new Properties();
Session session = Session.getInstance(props);
Store store = session.getStore(receiptorPro);
store.connect(“接受邮件服务器”, “端口”, “用户名”, “密码”);
打开Folder:
Folder inbox = store.getFolder("INBOX");
Folder有pop3和imap两种:
IMAPFolder folder = (IMAPFolder) inbox;
folder.open(Folder.READ_WRITE);//Folder.READ_WRITE为打开状态
获取邮件:
Message[] messages = folder.getMessages();
for (int i = 0; i < messages.length; i++) {
Date sendDate = messages[i].getSentDate();
//ok 就能取出发送时间
}

回答2:

哈哈哈~~我不知道啊!!