I use the following code to read the body of a message object:
Object content = _message.getContent();
String body = null;
if (content instanceof String) {
body = (String) content;
} else if (content instanceof Multipart) {
Multipart multipart = (Multipart) content;
BodyPart part = multipart.getBodyPart(0);
body = (String) part.getContent();
}
When the content is multi-user, everything works fine, but when the content is just text / regular, I get the following exception (already in the getContent () call on line 1!):
13.01.2011 17:22:23 org.zkoss.zk.ui.impl.UiEngineImpl handleError:1253
SCHWERWIEGEND: >>org.zkoss.zk.ui.UiException: java.io.IOException
java.io.IOException
at javax.mail.internet.MimePartDataSource.getInputStream(MimePartDataSource.java:108)
at com.sun.mail.handlers.text_plain.getContent(text_plain.java:90)
at javax.activation.DataSourceDataContentHandler.getContent(DataHandler.java:775)
at javax.activation.DataHandler.getContent(DataHandler.java:522)
at javax.mail.internet.MimeMessage.getContent(MimeMessage.java:1396)
I also tried the code shown in the JavaMail FAQ: http://www.oracle.com/technetwork/java/faq-135477.html#mainbody
The same result.
The message was recovered by calling getMessages (n) on the IMAPFolder instance. A folder instance comes from the IMAPStore object.
I completely rule out what could happen wrong ... Does anyone have any ideas?
source
share