获取javax.mail.multipart中的Missing Start Boundary。

huangapple go评论89阅读模式
英文:

getting Missing Start Boundary in javax.mail.multipart

问题

我正在尝试使用Java Mail API读取电子邮件。当我尝试从多部分中获取计数,就像这样:

multipart.getCount()

我收到了以下异常:

javax.mail.MessagingException: 缺少起始边界

	at javax.mail.internet.MimeMultipart.parsebm(MimeMultipart.java:872)
	at javax.mail.internet.MimeMultipart.parse(MimeMultipart.java:493)
	at javax.mail.internet.MimeMultipart.getCount(MimeMultipart.java:240)

非常感谢您的帮助。

英文:

I'm trying to read the emails using java mail API.

and when I tries to get count from multipart like this:

multipart.getCount()

I am getting the below exception:

javax.mail.MessagingException: Missing start boundary

	at javax.mail.internet.MimeMultipart.parsebm(MimeMultipart.java:872)
	at javax.mail.internet.MimeMultipart.parse(MimeMultipart.java:493)
	at javax.mail.internet.MimeMultipart.getCount(MimeMultipart.java:240)

Any help is appreciated.

答案1

得分: 1

这个问题可以通过 MimeMultipart 拥有的两个属性来解决...
我之前也遇到了同样的问题,我通过以下方式解决了它:

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

当你阅读 MimeMulutiPart.java 文件时,你会找到 5 个属性:

 1. mail.mime.multipart.ignoremissingendboundary (默认为 true)
 2. mail.mime.multipart.ignoremissingboundaryparameter (默认为 true)
 3. mail.mime.multipart.ignoreexistingboundaryparameter (默认为 false)
 4. mail.mime.multipart.allowempty (默认为 false)
 5. mail.mime.multipart.bmparse (默认为 true)

当我尝试将剩余的 false 设置为 true 时,对我起效了。

英文:

this issue can be resolved with the two properties that MimeMultipart holds...
I was also having the same issue and I resolved it with:

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

When you'll read the MimeMulutiPart.java, you'll find 5 properties:


 1. mail.mime.multipart.ignoremissingendboundary(def. true)
 2. mail.mime.multipart.ignoremissingboundaryparameter(def. true)
 3. mail.mime.multipart.ignoreexistingboundaryparameter(def. false)
 4. mail.mime.multipart.allowempty(def. false)
 5. mail.mime.multipart.bmparse(def. true)

and when I tried setting the remaining false to true. it worked for me.

huangapple
  • 本文由 发表于 2020年4月6日 12:20:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/61052902.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定