`
SpaceCity
  • 浏览: 97816 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

邮件发送(示例)

阅读更多
public static void sendMail() throws MessagingException {
Properties props = System.getProperties();
props.put("mail.smtp.host", "internet1.lotus.com");
Session session = Session.getInstance(props);

MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("luoyafei@cn.ibm.com"));
msg.addRecipient(RecipientType.TO, new InternetAddress(
"luoyafei@cn.ibm.com"));
msg.addRecipient(RecipientType.CC, new InternetAddress(
"luoyafei@cn.ibm.com"));
msg.addRecipient(RecipientType.BCC, new InternetAddress(
"luoyafei@cn.ibm.com"));
msg.setSubject("only test", "UTF-8");

Multipart mp = new MimeMultipart();
BodyPart part = new MimeBodyPart();
// html 格式
// part.setHeader("Content-Type", "text/html; charset=utf-8");
part.setText("test");
mp.addBodyPart(part);
msg.setContent(mp);

Transport.send(msg);
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics