当我从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();
}
收到的其他消息没有任何错误
最佳答案
邮件似乎已损坏。在“ 8bit”和“ Precedence”之间应该有换行符。如果您只是想忽略这些错误,可以将系统属性“ mail.mime.ignoreunknownencoding”设置为“ true”。