Bug 51446 - Can't extract embedded binary attachments(.msg) from a outlook .msg file
Summary: Can't extract embedded binary attachments(.msg) from a outlook .msg file
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: HSMF (show other bugs)
Version: 3.8-dev
Hardware: Other All
: P1 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-28 10:51 UTC by Ezequiel Foncubierta
Modified: 2021-03-03 02:39 UTC (History)
0 users



Attachments
RTF message (226.00 KB, application/octet-stream)
2011-06-28 10:51 UTC, Ezequiel Foncubierta
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ezequiel Foncubierta 2011-06-28 10:51:23 UTC
Created attachment 27222 [details]
RTF message

The attached file as been created as following (Microsoft Outlook 2007):

- Go to Tools -> Options -> Mail Format -> Signatures
- Create a new signature (e.g. Demo)
- Add a picture to your new signature (e.g. My Documents/My Pictures/Sample Pictures/Blue hills.jpg)
- Send an email using that signature
- Use the received message to do the test

I want to be able to extract the image data in the signature using MAPIMessage class, but the attachment has a null value in the attachData property.

On the other hand, this message has the following header:

Content-Type: application/ms-tnef; name="winmail.dat"
Comment 1 Nick Burch 2011-07-31 19:34:32 UTC
If the attachment data is empty, then that normally means there's a attachmentDirectory instead. Did you check that?
Comment 2 Selvakumar Vijayakumar 2012-04-06 19:00:02 UTC
Nick,

If the attachment data is empty, I can get the attachment as embedded message by using attachment.attachmentDirectory.getAsEmbededMessage() which helps to get the .msg attachment properties like ( from,CC,TO,BCC, etc).

But I have the special use case, where I want to get the embeddedMessage as binary. If I save the binary as .msg, I should able to open that with Microsoftoutlook. Is there anyway I can get the embedded message as binary?.

If this feature is not already there , Will you please add the functionality to extract the binary or InputStream for the given MAPIMessage?.

Thanks
Selva
Comment 3 Selvakumar Vijayakumar 2012-04-06 19:01:09 UTC
Nick,

If the attachment data is empty, I can get the attachment as embedded message
by using attachment.attachmentDirectory.getAsEmbededMessage() which helps to
get the .msg attachment properties like ( from,CC,TO,BCC, etc).

But I have the special use case, where I want to get the embeddedMessage as
binary. If I save the binary as .msg, I should able to open that with
Microsoftoutlook. Is there anyway I can get the embedded message as binary?.

If this feature is not already there , Will you please add the functionality to
extract the binary or InputStream for the given MAPIMessage?.

Thanks
Selva
Comment 4 Nick Burch 2012-04-09 17:43:55 UTC
The outlook format doesn't work that way, so there's no input stream to just fetch. Nested outlook files are stored expanded in the ole2 stream. (Other embedded files are typically stored as just the one entry, so they can be fetched directly)

You could try copying the root directory of the attachment into a new POIFSFileSystem (there's a POIFS util to help with that), and see if that plays nicely with a copy of outlook. That should work just fine with HSMF, as that's largely analogous to what getAsEmbededMessage() does, I just don't know if there's any extra magic that a .msg file needs for outlook that is stored outside of the directory