This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java mail attachement problem  RSS feed

 
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!