谁用过JDAVMail接收过hotmail邮件?
/*
* 文件名:HotmailDemo.java
* 创建时间:2004-9-14
* 创建者:liudong
*/
package com.clickcom.mail;
import java.util.Date;
import java.util.Properties;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
/**
* Hotmail邮件的收发器
* @author liudong
*/
public class HotmailDemo {
public static void main(String[] args) {
receive();
}
/**
* 邮件接收
*/
protected static void receive() {
try {
Properties prop = new Properties();
Session ses = Session.getInstance(prop);
//使用JDAVMail Provider
Store store = ses.getStore( "davmail ");
//无需指定服务器地址
store.connect(null, "你的帐号 ", "密码 ");
if (store.isConnected()) {
Folder inbox = store.getFolder( "INBOX ");
if (inbox.exists()) {
inbox.open(Folder.READ_ONLY);
int nCount = inbox.getMessageCount();
System.out.println( "Inbox contains " + nCount + " messages ");
// 依次显示收件箱中的每封邮件