Posted By:
Sandeep_Ipte
Posted On:
Sunday, May 6, 2001 09:52 PM
I am using java mail in servlet. I have use ENCTYPE= "multipart/form-data" method for getting information from user. I am also accepting file attachment from user. This information was parse successfully. I have use byte[] for storing contains of attach file. I have write following code for adding contains of the file to Mime part. Multipart mp = new MimeMultipart(); MimeBodyPart mbp = new MimeBodyPart(); // filehashtable is Hashtable used for storing files detail String filename = (String)filehashtable("filename"); byte buf[] = (byte[]) filehashtable.get("content"); String contype = (String)filehashtable.get("content-type"); mbp.setD
More>>
I am using java mail in servlet. I have use ENCTYPE= "multipart/form-data" method for getting information from user. I am also accepting file attachment from user. This information was parse successfully. I have use byte[] for storing contains of attach file. I have write following code for adding contains of the file to Mime part.
Multipart mp = new MimeMultipart();
MimeBodyPart mbp = new MimeBodyPart();
// filehashtable is Hashtable used for storing files detail
String filename = (String)filehashtable("filename");
byte buf[] = (byte[]) filehashtable.get("content");
String contype = (String)filehashtable.get("content-type");
mbp.setDataHandler(new DataHandler(new String(buf),contype));
mbp.setFileName(filename);
mp.addBodyPart(mbp);
The above code is running successfully when attachment file is of type "text/html", but
if attachment is .zip file then, i got following exception
Sending failed; nested exception is: javax.mail.MessagingException: IOException while sending message; nested exception is: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type application/x-zip-compressed
if attachment if .gif file then, i got following exception
Sending failed; nested exception is: javax.mail.MessagingException: IOException while sending message; nested exception is: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type image/gif
I want to know what is the problem. What is more require for handling this. I have also tested the contains of the file by writing it some other location. It is ok.
<<Less