Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java mail attachement problem

 
Nidhi Bhatnagar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using a byte array to send it as an attachment for reading Excel files. It works fine for a few files and for other even smaller files it does not show any error but does not send it either.
Any clues?
The code I am using is:
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setContent(messageBody.toString(),"text/html");
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
if( attachments != null) {
MimeBodyPart bodyPart = new MimeBodyPart();
DataSource ds = new ByteArrayDataSource(attachments, contentType,filename);
bodyPart.setDataHandler( new DataHandler(ds));
bodyPart.setDisposition( "attachment; filename=\"" + filename + "\"");
bodyPart.setFileName("zip_code.xls");
multipart.addBodyPart(bodyPart);
}
msg.setContent(multipart);
Transport.send(msg);
Any help is appreciated.
Thanks
Nidhi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic