java Email

liqiangmoai 2011-06-21 09:26:10
public static void sendHtmlEmail() {
String subject = "Test Mail";
Collection<String> sendTo = new ArrayList<String>();
sendTo.add("abc@gmail.com");
String htmlMessage = "<html><body><font size='15' color='red'>This is a test mail.</font></body></html>";

// Create email message
Email email = new SimpleEmail();
email.setHostName("smtp.gmail.com");
email.setSmtpPort(587);
email.setAuthenticator(new DefaultAuthenticator("username", "password"));
email.setTLS(true);
email.setFrom("user@gmail.com");
email.setSubject("TestMail");
email.setMsg("This is a test mail ... :-)");
email.addTo("foo@bar.com");
email.send();
}


public static void main(String args[]){
sendHtmlEmail();
}
}


开始运行!
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/mail/util/LineInputStream
at javax.mail.Session.loadProvidersFromStream(Session.java:928)
at javax.mail.Session.access$000(Session.java:174)
at javax.mail.Session$1.load(Session.java:870)
at javax.mail.Session.loadResource(Session.java:1084)
at javax.mail.Session.loadProviders(Session.java:889)
at javax.mail.Session.<init>(Session.java:210)
at javax.mail.Session.getInstance(Session.java:249)
at com.inbai.test.Send.<init>(Send.java:70)
at com.inbai.test.Send.main(Send.java:349)



是没找到包,还是包冲突啊?
...全文
54 点赞 收藏 1
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
fanpeng613 2011-06-23
NoClassDefFoundError,com/sun/mail/util/LineInputStream没找到这玩意
回复
相关推荐
发帖
非技术区
创建于2007-09-28

2.3w+

社区成员

Java 非技术区
申请成为版主
帖子事件
创建了帖子
2011-06-21 09:26
社区公告
暂无公告