Code is below:
MimeMessage mail = new MimeMessage(session);
mail.setFrom(from);
MimeMultipart multipart = new MimeMultipart("related");
MimeBodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent(bodyText, "text/html");
multipart.addBodyPart(htmlPart);
MimeBodyPart imgPart=new MimeBodyPart();
String path = "/ivr/imagelogos/accenture.jpg";
DataSource ds=new FileDataSource(path);
imgPart.setDataHandler(new DataHandler(ds));
imgPart.setHeader("Content-ID","the-img-1");
multipart.addBodyPart(imgPart);
mail.setContent(multipart);
mail.setSentDate(new Date());
mail.setHeader("X-Mailer", "ALS Notifier Build 1.0.0.10");
// send the message
Transport.send(mail);
This code will place in Unix box - image path is based on unix machine.
When i ran the code its giving error -
IOException while sending message
javax.mail.MessagingException: IOException while sending message;
nested exception is:
java.io.FileNotFoundException: /ivr/imagelogos/accenture.jpg (No such file or directory)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:676)
Can any body help me in this problem.