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( + "