aspose file tools*
The moose likes Servlets and the fly likes Java mail attachement problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Java mail attachement problem" Watch "Java mail attachement problem" New topic
Author

Java mail attachement problem

Nidhi Bhatnagar
Greenhorn

Joined: Mar 24, 2003
Posts: 1
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java mail attachement problem