javaMail 学习

javaMail核心类

Properties p=new Properties();

Session session=Session.getDefaultInstance(p);

我们常用到的是它的一个子类MimeMessage

MimeMessage message = new MimeMessage(session);
接下来就可以给Message添加各个 part 了,MimeMessage实现了MimePart
message.setContent("Hello", "text/plain"); 设置内容及MIME类型
message.setText("Hello");
message.setSubject("First");

Address address = new InternetAddress("[email protected]", "George Bush");
message.setFrom(address)
Address address[] = ...;
message.addFrom(address);
message.addRecipient(type, address)

                
  • Message.RecipientType.TO
  • Message.RecipientType.CC
  • Message.RecipientType.BCC




         

你可能感兴趣的:(javamail)