Hi,
I have a simple JavaMail code that reads a email message which contains
text & html. Sample code below. When I test it with an email which contains
HTML data, I consistently see this error. Any idea on how to read the
MimeMultipart body correctly? I saw similar errors in old post 2yrs ago
with very old appengine SDK versions.. But the code below should work for
all email content..
java.io.IOException: Truncated quoted printable data
at
org.apache.geronimo.mail.util.QuotedPrintableEncoder.decodeNonspaceChar(QuotedPrintableEncoder.java:597)
at
org.apache.geronimo.mail.util.QuotedPrintableEncoder.decode(QuotedPrintableEncoder.java:584)
at
org.apache.geronimo.mail.util.QuotedPrintableDecoderStream.read(QuotedPrintableDecoderStream.java:80)
at
org.apache.geronimo.mail.handlers.TextHandler.getContent(TextHandler.java:107)
at
javax.activation.DataSourceDataContentHandler.getContent(DataHandler.java:790)
at javax.activation.DataHandler.getContent(DataHandler.java:537)
at javax.mail.internet.MimeBodyPart.getContent(MimeBodyPart.java:392)
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
Object content = message.getContent();
if (content instanceof String) {
log.info("content = " + message.getContent());
} else {
MimeMultipart multiPart = (MimeMultipart)content;
printContent(multiPart);
}
======
private static void printContent(Multipart emailBody) {
try {
for (int i=0; i<emailBody.getCount(); i++) {
BodyPart part = emailBody.getBodyPart(i);
log.info(i + " body part content type = " + part.getContentType());
Object obj = null;
try {
obj = part.getContent();
log.info(" content object type = " + obj.getClass().getName());
} catch (IOException ioe) {
LogUtils.error(log, "Error in printContent", ioe);
}
if (obj instanceof String) {
log.info(i + " content is = " + obj.toString());
} else if (obj instanceof MimeMultipart){
printContent((Multipart)obj);
} else if (obj != null){
log.info("obj class type is " + obj.getClass().getName());
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-appengine-java/-/VzjOXP3gOMEJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.