Properties props = System.getProperties();
props.put("mail.smtp.host", "10.0.1.6");
Session session1 = Session.getDefaultInstance(props, null);
MimeMultipart multipart = new MimeMultipart("related");
MimeMessage message = new MimeMessage(session1);
message.setFrom(new InternetAddress(mailFromAddress));
message.setSubject(mailSubject);
MimeBodyPart messageBodyPart1 = new MimeBodyPart();
messageBodyPart1.setContent(mailContent, "text/html");
multipart.addBodyPart(messageBodyPart1);
FileDataSource fds1 = new FileDataSource(pdfFilePath);
MimeBodyPart messageBodyPart2 = new MimeBodyPart();
messageBodyPart2.setDataHandler(new DataHandler(fds1));
messageBodyPart2.setFileName(fds1.getName());
multipart.addBodyPart(messageBodyPart2);
message.setContent(multipart);
message.addRecipient(Message.RecipientType.TO,new InternetAddress("malathi@gmail.com"));
message.addRecipient(Message.RecipientType.CC,new InternetAddress(maatharasi@gmail.com));
Transport.send(message);
it is sending for few users the mail with attachments correctly but for few users, it is sending the mail but it is missing the attachments.
let me know if anybody is knowing the solution ASAP because the application is running in live server
|