Bug 44055 - No access to the "FROM" field in an Outlook MSG file using MAPIMessage
Summary: No access to the "FROM" field in an Outlook MSG file using MAPIMessage
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 3.0-dev
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2007-12-11 08:02 UTC by Mike Taylor
Modified: 2007-12-21 04:16 UTC (History)
0 users



Attachments
Patch to add access to the FROM field of an Outlook MSG file (4.49 KB, patch)
2007-12-11 08:04 UTC, Mike Taylor
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Taylor 2007-12-11 08:02:16 UTC
I’ve been using  org.apache.poi.hsmf.MAPIMessage to handle reading the contents
of Outlook MSG files and I noticed that for some reason there was no accessor
method for getting at the “FROM” field.

I’m not sure if this was omitted for a reason but its absence seemed strange so
I decided to try and add it.

I gleaned from the HSMF javadoc that the various fields in a MSG file can be
identified by looking for OLE nodes with the following name

__substg1.0_<chunk_id><chunk_type>

Where <chunk_type> is an arbitrary HEX code indicating what data type the
property has and <chunk_id> is an arbitrary HEX code that identifies each property.

I did some searching through some sample MSG files and narrowed down the FROM
field to one of the following two chunk Ids:  0x0042 or 0x0C1A
Both seemed to work equally well in the files I tested on.

This patch contains the following changes:

-	Added “displayFromChunk” to instance to org.apache.poi.hsmf.datatypes.Chunks
-	Added “getDispalyFrom” accessor method to org.apache.poi.hsmf.MAPIMessage
-	Added a method to org.apache.poi.hsmf.model.TestBlankFileRead to test reading
the “FROM” field
-	Added a method to org.apache.poi.hsmf.model.TestSimpleFileRead to test reading
the “FROM” field

I also added an overloaded constructor to MAPIMessage that takes in an
InputStream (as opposed to just a file name).  This change had nothing to do
with the accessing the “FROM” field but was useful for the interface I was
implementing and didn’t seem to cost anything in terms of extra complexity in
the code.
Comment 1 Mike Taylor 2007-12-11 08:04:07 UTC
Created attachment 21257 [details]
Patch to add access to the FROM field of an Outlook MSG file

-	Added “displayFromChunk” to instance to
org.apache.poi.hsmf.datatypes.Chunks
-	Added “getDispalyFrom” accessor method to
org.apache.poi.hsmf.MAPIMessage
-	Added a method to org.apache.poi.hsmf.model.TestBlankFileRead to test
reading the “FROM” field
-	Added a method to org.apache.poi.hsmf.model.TestSimpleFileRead to test
reading the “FROM” field
Comment 2 Nick Burch 2007-12-13 06:57:46 UTC
Thanks for this. We'll wait on Travis (who wrote the existing outlook code) to
check it over before committing.
Comment 3 Nick Burch 2007-12-21 04:16:55 UTC
Thanks for this, committed