当前位置: 代码迷 >> Java相关 >> [求助]邮件接受的一个运行错误?(已解决)
  详细解决方案

[求助]邮件接受的一个运行错误?(已解决)

热度:325   发布时间:2007-10-05 09:33:05.0
[求助]邮件接受的一个运行错误?(已解决)

下面是一个邮件接受的程序,望大家给提出解决方法:
import javax.mail.*;
import java.io.*;
import javax.mail.Transport;
import javax.mail.Message;
import javax.mail.Message.*;
import javax.mail.Session;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.InternetAddress;
import java.util.*;
import javax.activation.*;
public class ReceiveMail{
public ReceiveMail(String host,String username,String password)throws Exception{
Properties props=new Properties();
Session session=Session.getDefaultInstance(props,null);
Store store=session.getStore("pop3");
store.connect(host,username,password);
Folder folder=store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
Message message[]=folder.getMessages();
for(int i=0,n=message.length;i<n;i++){
System.out.println((i++)+":"+message[i].getFrom()[0]+"\t"+message[i].getSubject());
System.out.println("Do you wait read mesage!"+"YES to read QUIT to end");
if("YES".equals(reader)){
message[i].writeTo(System.out);
}else if("QUIT".equals(reader)){break;}
}

}
class MyAuthenticator extends javax.mail.Authenticator{
private String userName;
private String userPass;
public MyAuthenticator(String userName,String userPass){
this.userName=userName;
this.userPass=userPass;
}

}
public static void main(String[] args)throws Exception{
ReceiveMail d=new ReceiveMail("pop.163.com","xuchengli375","06335529170");

}
}
错误是 Exception in thread "main" javax.mail.NoSuchProviderException:No provider for pop3
我忘记在classpath中导入pop3.jar

[此贴子已经被作者于2007-10-5 10:19:20编辑过]

搜索更多相关的解决方案: 邮件  运行  

----------------解决方案--------------------------------------------------------
  相关解决方案