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.
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
Thanks for this. We'll wait on Travis (who wrote the existing outlook code) to check it over before committing.
Thanks for this, committed