I started by reading this thread, but still encountered the same problem. (Truthfully i thought i was adding a reply to that thread but seems i started a new one.)
I am quite confident i am not doing the wrong thing. It appears that hotmail may not be encoding quoted-printable chars correctly (at least as far as the decoder is concerned) and i found the problem to be the occasional escaping of newlines with an =<newline>. The decoder appears to want a two digit hex after the equal sign. The decoder fails at this point as does the apache decoder which i also tested. I worked around this problem by accessing the RawInputStream and decoding the text message myself. However MimeMessage.getContent() throws an exception and i believe this to be a bug in the GAE implementation, if not that it could be more lenient in parsing quoted- printable streams. I would be glad to share my workaround, but would also like to see a fix in the GAE code. My workaround looks something like this: // email arriving from hotmail Object content; try { content = mimeMessage.getContent(); // or mimeBodyPart } catch (Exception e) { // when quoted-printable decoding IOException: Truncated quoted printable data content = LenientQuotedPrintableDecoder.decode( mimeMessage.getRawInputStream()); // returns String } On Feb 12, 3:12 am, seleronm <seler...@gmail.com> wrote: > Hi, > > It is likely already to have tried. > > This might be useful. > Follow this > thread:http://groups.google.com/group/google-appengine-java/browse_thread/th... > > Please try. > thanks. > > On 2月11日, 午前10:36,moca<jwein...@gmail.com> wrote: > > > > > I am receiving the error below when receiving an email from Hotmail to > > an App Engine email Servlet. The same code works fine when receiving > > emails from Gmail and my cell for instance. > > > gui.EMailReceiverServlet doPost: Truncated quoted printable data > > java.io.IOException: Truncated quoted printable data > > at > > org.apache.geronimo.mail.util.QuotedPrintableEncoder.decodeNonspaceChar(Quo > > tedPrintableEncoder.java: > > 597) > > at > > org.apache.geronimo.mail.util.QuotedPrintableEncoder.decode(QuotedPrintable > > Encoder.java: > > 584) > > at > > org.apache.geronimo.mail.util.QuotedPrintableDecoderStream.read(QuotedPrint > > ableDecoderStream.java: > > 80) > > at > > org.apache.geronimo.mail.handlers.TextHandler.getContent(TextHandler.java: > > 107) > > at javax.activation.DataSourceDataContentHandler.getContent(Unknown > > Source) > > at javax.activation.DataHandler.getContent(Unknown Source) > > at javax.mail.internet.MimeMessage.getContent(MimeMessage.java:927) > > > Fails early when sending email from Hotmail using "Plain Text" > > > try { > > Properties props = new Properties(); > > Session session = Session.getDefaultInstance(props, null); > > MimeMessage message = new MimeMessage(session, > > request.getInputStream()); > > > Address[] messageFrom = message.getFrom(); > > Address messageSender = message.getSender(); > > Address[] messageReplyTo = message.getReplyTo(); > > String messageSubject = message.getSubject(); > > Date messageSentDate = message.getSentDate(); > > String messageContentType = message.getContentType(); > > > LOGGER.info("received email message.from: " > > + Arrays.toString(messageFrom) + " message.sender: > > " > > + messageSender + " message.replyTo: " > > + Arrays.toString(messageReplyTo) + " > > message.subject: " > > + messageSubject + " message.sentDate: " + > > messageSentDate > > + " message.contentType: " + messageContentType); > > > Object messageContent; > > try { > > messageContent = message.getContent(); // THIS SHOULD > > WORK > > } catch (Exception e) { > > LOGGER.log(Level.SEVERE, e.getMessage(), e); > > > ByteArrayOutputStream out = new > > ByteArrayOutputStream(); > > message.writeTo(out); > > > A Snippet of what is printed by message.writeTo() > > (Notice the Content-Transfer-Encoding: quoted-printable and the > > exception: java.io.IOException: Truncated quoted printable data) > > > Date: Wed, 10 Feb 2010 17:16:32 -0800 > > Importance: Normal > > Content-Type: text/plain; charset="Windows-1252" > > Content-Transfer-Encoding: quoted-printable > > MIME-Version: 1.0 > > X-OriginalArrivalTime: 11 Feb 2010 01:16:33.0369 (UTC) > > FILETIME=[D93A3C90:01CAAAB7] > > > app =20 > > > FYI: My message was "app" > > > My message comes in, but it is not correctly parsed by the mail > > implementation. > > > Does anyone know how to work around this?? > > > Thanks -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.