Java邮件API发送邮件附带另一个邮件



我想问我如何用Java邮件API发送带有附件的另一封邮件。

MimeBodyPart attachmentPart = new MimeBodyPart ( );
attachmentPart.setContent ( mail , "text/?" );

提前感谢!

javax.mail.Multipart multipart = new MimeMultipart();
javax.mail.internet.MimeBodyPart messageBodyPart =   new  javax.mail.internet.MimeBodyPart();
multipart.addBodyPart(messageBodyPart);
javax.activation.DataSource source = new FileDataSource("C:\Notes\new mail.msg");
messageBodyPart.setDataHandler( new DataHandler(source));
messageBodyPart.setFileName("new mail.msg");
multipart.addBodyPart(messageBodyPart);
msg.setContent(multipart);
 MimeBodyPart part = new MimeBodyPart();
 part.setText(text);
multipart.addBodyPart(part);

相关内容

  • 没有找到相关文章

最新更新