标签:
MultiPartEmail email = new MultiPartEmail();
email.setDebug(true);
email.setHostName("smtp.sina.com");
email.setAuthentication("发送邮件帐号", "邮箱登录密码");
email.setCharset("UTF-8");
try {
email.setFrom("发送邮件帐号", "用户名");
email.addTo("接受邮件帐号", "用户名");
email.setSubject("主题");
email.setMsg("正文");
EmailAttachment ment = new EmailAttachment();
ment.setPath(附件的绝对路径");
ment.setName(MimeUtility.encodeText("附件在邮件中显示的名称,也是下载保存的名字[需要带后缀]"));
// 将附件添加到邮件zhong
email.attach(ment);
email.send();
} catch (EmailException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
标签:
原文地址:http://www.cnblogs.com/denglibin/p/5704219.html