Index: C:/eclipse/workspace/POI/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java =================================================================== --- C:/eclipse/workspace/POI/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java (revision 595692) +++ C:/eclipse/workspace/POI/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java (working copy) @@ -48,15 +48,24 @@ /** - * Constructor for reading MSG Files. + * Constructor for reading MSG Files from the file system. * @param filename * @throws IOException */ public MAPIMessage(String filename) throws IOException { - InputStream in = new FileInputStream(new File(filename)); + this(new FileInputStream(new File(filename))); + } + + /** + * Constructor for reading MSG Files from an input stream. + * @param in + * @throws IOException + */ + public MAPIMessage(InputStream in) throws IOException { this.fs = new POIFSFileSystem(in); chunkParser = new POIFSChunkParser(this.fs); } + /** * Gets a string value based on the passed chunk. @@ -102,6 +111,16 @@ } /** + * Gets the display value of the "FROM" line of the outlook message + * This is not the actual address that was sent from but the formated display of the user name. + * @return + * @throws ChunkNotFoundException + */ + public String getDisplayFrom() throws ChunkNotFoundException { + return getStringFromChunk(Chunks.getInstance().displayFromChunk); + } + + /** * Gets the display value of the "TO" line of the outlook message * This is not the actual list of addresses/values that will be sent to if you click Reply in the email. * @return Index: C:/eclipse/workspace/POI/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java =================================================================== --- C:/eclipse/workspace/POI/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java (revision 595692) +++ C:/eclipse/workspace/POI/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java (working copy) @@ -29,6 +29,7 @@ public StringChunk textBodyChunk = new StringChunk(0x1000); //BODY Chunk, for plain/text messages public StringChunk subjectChunk = new StringChunk(0x0037); //Subject link chunk, in plain/text public StringChunk displayToChunk = new StringChunk(0x0E04); //Value that is in the TO field (not actually the addresses as they are stored in recip directory nodes + public StringChunk displayFromChunk = new StringChunk(0x0C1A); //Value that is in the FROM field public StringChunk displayCCChunk = new StringChunk(0x0E03); //value that shows in the CC field public StringChunk displayBCCChunk = new StringChunk(0x0E02); //Value that shows in the BCC field public StringChunk conversationTopic = new StringChunk(0x0070); //Sort of like the subject line, but without the RE: and FWD: parts. Index: C:/eclipse/workspace/POI/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestBlankFileRead.java =================================================================== --- C:/eclipse/workspace/POI/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestBlankFileRead.java (revision 595692) +++ C:/eclipse/workspace/POI/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestBlankFileRead.java (working copy) @@ -84,6 +84,21 @@ } /** + * Test to see if we can read the FROM Chunk. + * @throws ChunkNotFoundException + * + */ + public void testReadDisplayFrom() throws ChunkNotFoundException { + try { + mapiMessage.getDisplayFrom(); + } catch(ChunkNotFoundException exp) { + return; + } + + TestCase.fail("Should have thrown a ChunkNotFoundException but didn't"); + } + + /** * Test to see if we can read the CC Chunk. * @throws ChunkNotFoundException * Index: C:/eclipse/workspace/POI/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestSimpleFileRead.java =================================================================== --- C:/eclipse/workspace/POI/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestSimpleFileRead.java (revision 595692) +++ C:/eclipse/workspace/POI/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestSimpleFileRead.java (working copy) @@ -67,6 +67,18 @@ } /** + * Test to see if we can read the From Chunk. + * @throws ChunkNotFoundException + * + */ + public void testReadDisplayFrom() throws ChunkNotFoundException { + String obtained = mapiMessage.getDisplayFrom(); + String expected = "Travis Ferguson"; + + TestCase.assertEquals(obtained, expected); + } + + /** * Test to see if we can read the CC Chunk. * @throws ChunkNotFoundException *