Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do I set the mime type for an attachment to "application/zip"

843830Aug 5 2002 — edited Aug 5 2002
I'm sending out an email with a zip file as an attachment. The following code works fine, but the Mimetype for the attachment is set to "application/octet-stream"

FileDataSource fds = new FileDataSource(zipname);
DataHandler dh = new DataHandler(fds);
MimeBodyPart mbp2 = new MimeBodyPart();
mbp2.setDataHandler(dh);
mbp2.setFileName(fds.getName());

I would like the mime type to be application/x-zip. Unfortunately I seem to need a data content handler for this mime type as I get this exception.

javax.activation.UnsupportedDataTypeException: no object DCH for MIME type application/x-zip


Building a date content handler in the activation framework seems like a lot of work to do a very simple thing. Am I missing something obvious? Is there a simple way to do this?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 2 2002
Added on Aug 5 2002
1 comment
822 views