Problem with sending attachments with JavaMail API and Java1.5
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Karin_Garreis
Posted On:   Friday, July 22, 2005 05:36 AM

Hello, I'm currently trying to set up a HTML form with some input text fields and a file upload field. The data is then handled by a Java Servlet and underlying Java classes. They are trying to send the data via e-mail. The e-mail is send, however, when you retrieve it, it is not readable, and I have the following message in the mail [MIME content for this item is stored in attachment $RFC822.eml. Parsing MIME content failed: Incorrect format in MIME data..] I'm using the Java code snippet I found here at jguru relating to attachments. Funnily enough I had it working properly with Java Version 1.4.2. The e-mail is also retrieved properly when I leave out the attachment code in my classes. Another f   More>>

Hello,

I'm currently trying to set up a HTML form with some input text fields and a file upload field. The data is then handled by a Java Servlet and underlying Java classes. They are trying to send the data via e-mail.


The e-mail is send, however, when you retrieve it, it is not readable, and I have the following message in the mail

[MIME content for this item is stored in attachment $RFC822.eml. Parsing MIME content failed: Incorrect format in MIME data..]


I'm using the Java code snippet I found here at jguru relating to attachments. Funnily enough I had it working properly with Java Version 1.4.2. The e-mail is also retrieved properly when I leave out the attachment code in my classes.


Another funny thing I recognized is that I'm not able to use enctype="multipart/form-data" in my HTML because I'm not getting any parameter data then. I tried to get around this, to check if this solves my e-mail problem, but it didn't change anything.


Has anyone experienced similar problems? Is there possibility to tell the Multipart object which MIME-type to use? Any help/ideas/suggestions are really appreciated!


Regards, Karin    <<Less

Re: Problem with sending attachments with JavaMail API and Java1.5

Posted By:   Anonymous  
Posted On:   Friday, July 22, 2005 07:08 AM

HI
Try to set the mime type to text/html
try with the following code ..


// Use Multipart inoder to handle attachments ..
Multipart mailBody = new MimeMultipart();

// set the mime type ....creating the mime type ...
MimeBodyPart mainBody = new MimeBodyPart();
DataHandler dh = new DataHandler(messageText, "text/html");
mainBody.setDataHandler(dh);
// attach the body to the MainBody.
mailBody.addBodyPart(mainBody);

// add attachements now .. and send the email
Regards Kalyan


U can reach me at kalyansyamala@yahoo.com
About | Sitemap | Contact