MessagingExceptionIOException while sending message in java?

前端 未结 8 1055
说谎
说谎 2021-01-19 02:41

I use the following code to send mail.Text message sending is working fine but Mail with attachment is not working it gives the Exception.How to solve this

8条回答
  •  北荒
    北荒 (楼主)
    2021-01-19 03:04

    static {
         // add handlers for main MIME types
        MailcapCommandMap mcap = new MailcapCommandMap();
        mcap.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
        mcap.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
        mcap.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
        mcap.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed; x-java-fallback-entry=true");
        mcap.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
        CommandMap.setDefaultCommandMap(mcap);
    }
    

提交回复
热议问题