谁用过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 ");
// 依次显示收件箱中的每封邮件
for(int i=1;i <=nCount;i++){
MimeMessage msg = (MimeMessage) inbox.getMessage(i);
System.out.println( "Subject : " + msg.getSubject());
System.out.println( "From : " + msg.getFrom()[0].toString());
System.out.println( "Content type : " + msg.getContentType());
System.out.println(msg.getContent());
}
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
我用netbeans建立了一个javaApplication工程,并导入了JDAVMail.0.9.006.jar,
运行时这行Store store = ses.getStore( "davmail ");老报错
javax.mail.NoSuchProviderException: No provider for davmail
请问怎么回事
[解决办法]
试试在控制台下运行有没问题(设置相关jar文件的classpath),