0

当我从 POP3 收到电子邮件时,出现以下错误

Fatal exception java.io.IOException: Unknown encoding: 8bitPrecedence
at javax.mail.internet.MimePartDataSource.getInputStream(MimePartDataSource.java:109)
at com.sun.mail.handlers.text_plain.getContent(text_plain.java:107)
at javax.activation.DataSourceDataContentHandler.getContent(DataHandler.java:790)
at javax.activation.DataHandler.getContent(DataHandler.java:537)
at javax.mail.internet.MimeMessage.getContent(MimeMessage.java:1419)

源代码

Session session = property.getSession();
HashMap<String, String> isNotified = Util.getIsNotified(connection, userId);
store = session.getStore("pop3");
store.connect();
inbox = store.getFolder("INBOX");
inbox.open(Folder.READ_ONLY);
int count       = inbox.getMessageCount();
for(int i = 0; i < count; i++)
{
    Message message     = inbox.getMessage(i);
    Object content = message.getContent();
}

收到的其他消息没有任何错误

4

1 回答 1

1

看起来消息已损坏。“8bit”和“Precedence”之间应该有一个换行符。如果您只想忽略这些错误,可以将系统属性“mail.mime.ignoreunknownencoding”设置为“true”。

于 2012-11-09T04:48:48.570 回答