Reputation: 1652
I want to ask how can I send a message with Java Mail API with attachment another mail.
MimeBodyPart attachmentPart = new MimeBodyPart ( );
attachmentPart.setContent ( mail , "text/?" );
Thanks in advance!
Upvotes: 0
Views: 668
Reputation: 547
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);
Upvotes: 2