Javamail API を使用して送信済みアイテムをメールに保存するにはどうすればよいですか?
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
Session session = Session.getInstance(props,new javax.mail.Authenticator() {
protected PasswordAuthenticationgetPasswordAuthentication() {
return new PasswordAuthentication("user id","pwd");
}
});
Message message = new MimeMessage(session);
message.setHeader("X-Priority","1");
message.setFrom(new InternetAddress("user id"));
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(Toaddress));
message.addRecipients(Message.RecipientType.CC,InternetAddress.parse(cc));
message.setSubject("Subject");
Multipart multipart = new MimeMultipart();
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText("test mail");
Transport.send(message);