Missing start boundary Exception when reading messages with an attachment file

前端 未结 2 756
一个人的身影
一个人的身影 2021-01-05 04:53

I don\'t know why I\'m getting the following exception when reading a mail with an attachment file from mail server:

Exception in thread \"main\" javax.mail.         


        
相关标签:
2条回答
  • 2021-01-05 05:27

    I've just had the same problem. The boundary is specified within the Multipart Content-Type. You can find further information in this source. You can also watch the one of your current Message using the getContentType() function. In my case I obtained this result:

    multipart/mixed; boundary=--boundary_25_2d74d02b-d0d6-4f28-a311-4d1b7d107417
    

    So the getCount() function uses this boundary to separate all the parts that compose the multiple part. Looks like there could be cases in which this boundary is corrupted.

    The mail.mime.multipart.ignoreexistingboundaryparameter System property may be set to true to cause any boundary to be ignored and instead search for a boundary line in the message as with mail.mime.multipart.ignoremissingboundaryparameter.

    I followed this instructions and everything works all right. I added the code below:

    System.setProperty("mail.mime.multipart.ignoreexistingboundaryparameter", "true");
    

    Hope it helps!

    0 讨论(0)
  • 2021-01-05 05:41

    try to set mode on the multipartEntityBuilder ex: multipartEntityBuilder.setMode(HttpMultipartMode.RFC6532);

    0 讨论(0)
提交回复
热议问题