From: Nick Burch Date: Fri, 1 Apr 2011 14:51:45 +0000 (+0000) Subject: Improve HSMF encoding guessing for 7 bit fields, and allow HSMF access to the HTML... X-Git-Tag: REL_3_8_BETA3~77 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=dcdb268d3bffa6fb652dbd4a15fd7afe788da608;p=poi.git Improve HSMF encoding guessing for 7 bit fields, and allow HSMF access to the HTML body contents in MAPIMessage git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1087726 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 2730545cce..c619413f20 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -33,6 +33,10 @@ + + Improve HSMF encoding guessing for 7 bit fields in MAPIMessage + Allow HSMF access to the HTML body contents in MAPIMessage + Implement the load method on MemoryPackagePart 50967 - Support for continued ExtSSTRecords diff --git a/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java b/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java index f220ebfe55..e9cc82d14d 100644 --- a/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java +++ b/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java @@ -176,6 +176,16 @@ public class MAPIMessage extends POIDocument { return getStringFromChunk(mainChunks.textBodyChunk); } + /** + * Gets the html body of this Outlook Message, if this email + * contains a html version. + * @return The string representation of the 'html' version of the body, if available. + * @throws ChunkNotFoundException + */ + public String getHmtlBody() throws ChunkNotFoundException { + return getStringFromChunk(mainChunks.htmlBodyChunk); + } + /** * Gets the subject line of the Outlook Message * @throws ChunkNotFoundException @@ -331,28 +341,59 @@ public class MAPIMessage extends POIDocument { if(m.matches()) { // Found it! Tell all the string chunks String charset = m.group(1); - - for(Chunk c : mainChunks.getAll()) { - if(c instanceof StringChunk) { - ((StringChunk)c).set7BitEncoding(charset); - } - } - for(Chunk c : nameIdChunks.getAll()) { - if(c instanceof StringChunk) { - ((StringChunk)c).set7BitEncoding(charset); - } - } - for(RecipientChunks rc : recipientChunks) { - for(Chunk c : rc.getAll()) { - if(c instanceof StringChunk) { - ((StringChunk)c).set7BitEncoding(charset); - } - } - } + set7BitEncoding(charset); + return; } } } } catch(ChunkNotFoundException e) {} + + // Nothing suitable in the headers, try HTML + try { + String html = getHmtlBody(); + + // Look for a content type in the meta headers + Pattern p = Pattern.compile( + "