Caused by: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/related; boundary="----=_Part_0_9042915.1299319807397" at javax.activation.ObjectDataContentHandler.writeTo(Unknown Source) at javax.activation.DataHandler.writeTo(Unknown Source) at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1383) at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1743) at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:888) ... 4 moreThere is something wrong with MailCap, javamail can not find a handler for such multipart/mixed part.
And the solution is add mime programmingly:
MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html"); mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml"); mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain"); mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822"); CommandMap.setDefaultCommandMap(mc);