Posted By:
Makesh_Rao
Posted On:
Friday, April 19, 2002 01:18 PM
I have written a client code to send a multipart/mixed message, using JavaMail api. The mail seems to be fine as I find it when I dump it to a file. I just write the message to a URL. using the writeTo method of the message. On the server side, I have a servlet that accepts the request. I get the inputstream from the request and create a message out of it : //Create session before this MimeMessage message = new Message(session, request.getInputStream()); //I thought this might help.. MailcapCommandMap map = new MailcapCommandMap(); map.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain"); map.addMailcap("multipart/*;
More>>
I have written a client code to send a multipart/mixed message, using JavaMail api. The mail seems to be fine as I find it when I dump it to a file. I just write the message to a URL. using the writeTo method of the message.
On the server side, I have a servlet that accepts the request. I get the inputstream from the request and create a message out of it :
//Create session before this
MimeMessage message = new Message(session, request.getInputStream());
//I thought this might help..
MailcapCommandMap map = new MailcapCommandMap();
map.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
map.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
CommandMap.setDefaultCommandMap(map);
Multipart multipart = (Multipart)message.getContent();
BodyPart bodyPart = ((Multipart)multipart).getBodyPart(0);
When I get to the part where I try to get the Bodypart, I get a
javax.mail.internet.ParseException
. I tried to get the count of the parts in the Multipart. The count returns 0.
If I try to cast the object returned with message.getContent() to a String and print it, it prints the entire message that was sent from the client, including the attachment.
Any ideas ...
Makesh
<<Less