public static void send(String toemail,String toname,String subject,String content) throws EmailException{//不带附件发送邮件
String fromemail = "***@ewccglobal.com.cn";
String fromname = "Ewcc Reminder";
String password = "***";
HtmlEmail multipartemail = new HtmlEmail();
multipartemail.setHostName("smtp.ewccglobal.com.cn");
multipartemail.addTo(toemail, toname);
multipartemail.setFrom(fromemail, fromname);
multipartemail.setAuthentication(fromemail, password);
multipartemail.setSubject(subject);
multipartemail.setCharset("gb2312");
multipartemail.setHtmlMsg(content);
multipartemail.send();
}
public static void send(String toemail,String toname,String subject,String content,List<String> filepath) throws EmailException, MalformedURLException{//带附件发送邮件
String fromemail = "***@ewccglobal.com.cn";
String fromname = "Ewcc Reminder";
String password = "******";
HtmlEmail multipartemail = new HtmlEmail();
multipartemail.setHostName("smtp.ewccglobal.com.cn");
multipartemail.addTo(toemail, toname);
multipartemail.setFrom(fromemail, fromname);
multipartemail.setAuthentication(fromemail, password);
multipartemail.setSubject(subject);
multipartemail.setCharset("gb2312");
multipartemail.setHtmlMsg(content);
//附件
if(filepath!=null && filepath.size()>0){
for(int i=0; i<filepath.size();i++){
EmailAttachment attac = new EmailAttachment();
attac.setPath(filepath.get(i));
multipartemail.attach(attac);
}
}
//附件
multipartemail.send();
System.out.println("The attachmentEmail send sucessful!!!");
}
jar包下载