日期:2014-05-18 浏览次数:20744 次
public static void main(String args[]) throws Exception {
Properties props = System.getProperties();
props.put("mail.smtp.host", "smtp.163.com");
props.put("mail.smtp.auth", "true");
Session session = Session.getDefaultInstance(props, null);
URLName urln = new URLName("pop3", "pop3.163.com", 110, null,
"emailAddress", "password"); //邮箱帐号密码正确
Store store = session.getStore(urln);
store.connect();
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
Message[] message = folder.getMessages();
System.out.println("Messages's length: " + message.length);
ReciveMail pmm = null;
for (int i = 0; i < message.length; i++) {
System.out.println("======================");
Message msg = message[i];
//System.out.println(msg.getSubject());
pmm = new ReciveMail((MimeMessage) message[i]);
System.out.println("Message " + i + " subject: " + pmm.getSubject());
System.out.println("Message " + i + " sentdate: "+ pmm.getSentDate());
System.out.println("Message " + i + " replysign: "+ pmm.getReplySign());
System.out.println("Message " + i + " hasRead: " + pmm.isNew());
System.out.println("Message " + i + " containAttachment: "+ pmm.isContainAttach((Part) message[i]));
System.out.println("Message " + i + " form: " + pmm.getFrom());
&nb