/** * Parses untruncated MIME data, saving away the text parts * * @param msg the message we're building * @param mimeData the MIME data we've received from the server * @throws IOException */ private static void mimeBodyParser(EmailContent.Message msg, String mimeData) throws IOException { try { ByteArrayInputStream in = new ByteArrayInputStream(mimeData.getBytes()); // The constructor parses the message MimeMessage mimeMessage = new MimeMessage(in); // Now process body parts & attachments ArrayList<Part> viewables = new ArrayList<Part>(); // We'll ignore the attachments, as we'll get them directly from EAS ArrayList<Part> attachments = new ArrayList<Part>(); MimeUtility.collectParts(mimeMessage, viewables, attachments); // parseBodyFields fills in the content fields of the Body ConversionUtilities.BodyFieldData data = ConversionUtilities.parseBodyFields(viewables); // But we need them in the message itself for handling during commit() msg.setFlags(data.isQuotedReply, data.isQuotedForward); msg.mSnippet = data.snippet; msg.mHtml = data.htmlContent; msg.mText = data.textContent; } catch (MessagingException e) { // This would most likely indicate a broken stream throw new IOException(e); } }