tags:

views:

391

answers:

2

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.

+1  A: 

Sounds like the /ivr/imagelogos/accenture.jpg file doesn't exist. Are you sure that's the right path? Maybe it's supposed to be relative to some other path? If it does exist, does the user running the Java app have read permissions on it?

Eric Petroelje
A: 
Update your question, don't add new answers.
matt b
Check MimeMessage.java line 856 and try to find out where that send date is set. The set it :)
extraneon