Bug 58211 - Implement write() method in MAPIMessage class.
Summary: Implement write() method in MAPIMessage class.
Alias: None
Product: POI
Classification: Unclassified
Component: HSMF (show other bugs)
Version: 3.13-dev
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2015-08-05 07:55 UTC by Alexandre
Modified: 2015-08-05 11:56 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Alexandre 2015-08-05 07:55:38 UTC
Currently, the method write() in the class MAPIMessage  return an   UnsupportedOperationException. 
Is it possible to implement this method ?

I try to save an Outlook message in attachment of an Outlook msg. Right now there is no way to do this. (without having an error when opening the message)

Comment 1 Nick Burch 2015-08-05 08:37:19 UTC
To save out an attachment, your only current route is to grab the POIFS Directory that holds it, then use EntryUtils to save that into a new empty NPOIFS instance

A write method would be good though, we'd love a patch with unit tests if you have time to write one!
Comment 2 Alexandre 2015-08-05 09:58:34 UTC
The way you describe to save out an attachment works fine with all  kinds of documents except outlook msg files.
Msg files saved using this method will generate an error when I try to open it in Outlook. Outlook does not recognize the file saved.
Maybe I should open a bug about that.

I would like to provide you with a patch, unfortunately I have not enough knowledge about msg format.
Comment 3 Nick Burch 2015-08-05 10:11:17 UTC
There must be some additional changes needed / bits missing when a msg attachment gets written out

What would be helpful is if you could create a simple small sample message, with an attachment inside it. Raise a new bug for the msg attachment saving, and upload there the outer message, the outlook-saved attachment, and the POI saved attachment. Bonus marks if you can also run some of the POI dev tools (eg org.apache.poi.poifs.dev.POIFSLister) to compare how the POI-saved and Outlook-saved attachments differ

As for learning about the file format, the latest file format specs are available publicly at: https://msdn.microsoft.com/en-us/library/cc463912%28v=exchg.80%29.aspx?f=255&MSPPError=-2147217396
Comment 4 Alexandre 2015-08-05 11:56:15 UTC
Okey, i will create a new bug with required files to solve the problem.