Skip to Content
0
Former Member
Mar 09, 2004 at 12:29 PM

JavaMail : no object DCH for MIME type Application/XML

341 Views

Hi,

I am trying to set an Application/XML content on to a MimeBodyPart which results in the following exception:

javax.activation.UnsupportedDataTypeException: no object DCH for MIME type application/xml.

I am getting this error when I am doing an explicit setContent with the "application/xml" content type as depicted below. (The XML content is the form of a byte array.)

ByteArrayOutputStream os = new ByteArrayOutputStream();

os.write(byteArray);

MimeBodyPart mbp = new MimeBodyPart();

mbp.setContent(os, contentType);

In order to avoid this, do I neccessarily have to create a Data content handler for the Application/XML content type? And How do I do it?

I was able to avert this problem through a clumsy way of setting the content as a FileDataSource (fds):

tempFile = File.createTempFile("test","temp");

fos = new FileOutputStream(tempFile);

fos.write(byteArray);

fos.flush();

fos.close();

fds = new FileDataSource(tempFile);

fds.setFileTypeMap(mpFileTypeMap);

DataHandler dh = new DataHandler(fds);

mbp.setDataHandler(dh);

Can somebody point me to the right solution?

Best Regards,

S.Karthik

XI Development