JavaMail depends on some configuration files to map MIME types to Java classes (e.g., multipart/mixed
to javax.mail.internet.MimeMultipart
). These configuration files are loaded using the ClassLoader for the application. If the ClassLoader doesn’t function properly, these configuration files won’t be found.
You can simply add below lines .. that solves the issue .
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");