javamail的一个最初级的问题!
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
class MailExample
{
public static void main(String[] args) throws Exception
{
String toAddr="jin24@163.net";
String fromAddr="jin24@21cn.com";
String subject="测试!";
String body="welcome javamail";
try{
Properties props = new Properties();
props.put("mail.smtp.host","smtp.163.net");
Session sesion = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(sesion);
msg.setFrom(new InternetAddress(fromAddr));
msg.setRecipient(Message.RecipientType.TO,new InternetAddress(toAddr));
msg.setSubject(subject);
msg.setText(body);
Transport.send(msg);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
编译通过,运行时提示javax.mail.NoSuchProviderException: No provider for Address type: rfc822