Java Mail Send message no object DCH for MIME type multipart/mixed positive solution

Source: Internet
Author: User

In the development of the machine, the mail is not a problem, and generally should not have any problems, Commons_email and Javax.mail collocation for a long time, low-level problems should almost no, but upload to the server, no

Javax.activation.UnsupportedDataTypeException:no object DCH for MIME type multipart/mixed

Before usually is htmlmail, this time has the attachment, therefore is multipartmail, the result problem is out here, removes the attachment not to be possible.

The reason can also estimate a probably, plus exception information, must be the problem of mime, and the Web application in Web-inf/web.xml did not specify application holder the same truth, But how do you specify it in Multipartmail?

Put the dog

Find out to set mailcap in the local, invalid, say, local also did not set, should not be this problem.

Check again, generally think is the question of javax.activation and jdk6, but I have the same version on both sides, not

But where is this thing specified, check jar bag meta-inf, found activation have mailcap.default, Mail.jar have mailcap, and local no activation also run normal, should be packing problem.

See Build.xml, found in order to avoid the previous unknown problem, in Unjar all jars and packaging, removed Meta-inf, remember to avoid index.list conflict problems, but also the previous Ant bug

This should be the problem, repackage, OK

In addition, it can also be mail.send before, manually add such a paragraph

Mailcapcommandmap MC = (MAILCAPCOMMANDMAP) commandmap
. Getdefaultcommandmap ();
. Addmailcap ("text/html;; X-java-content-handler=com.sun.mail.handlers.text_html ");
. Addmailcap ("text/xml;; X-java-content-handler=com.sun.mail.handlers.text_xml ");
. Addmailcap ("text/plain;; X-java-content-handler=com.sun.mail.handlers.text_plain ");
. Addmailcap ("multipart/*;; X-java-content-handler=com.sun.mail.handlers.multipart_mixed ");
. Addmailcap ("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822 ");
Commandmap.setdefaultcommandmap (MC);

Article Source:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.