Difference between MapiAttachment.Save(...) and MapiAttachment.ObjectData.Data for OLE attachment

I believe I found a bug when using MapiAttachment.Save(Stream stream) on an OLE attachment (attachment with PR_ATTACH_METHOD == ATTACH_OLE).

On the message I was testing with, I noticed that using MAPI to download the OLE attachment I got a file with a size of 1,108,992 bytes, but when I used MapiAttachment.Save(Stream stream) to save the attachment, I got a file with a size of 1,098,214 bytes.

I found that if I just saved the contents of MapiAttachment.ObjectData.Data to disk, I got the same bytes that MAPI gave me (confirmed by SHA256).

So, it seems that MapiAttachment has the correct data, but MapiAttachment.Save(Stream stream) saves it incorrectly for OLE attachments – at least for the one that I was testing with.

@weswes

It appears you’ve encountered a known issue with MapiAttachment.Save(Stream stream) when handling OLE attachments. The discrepancy in file sizes suggests that the method may not be correctly processing the data for these specific attachment types.

As you’ve noted, saving the contents of MapiAttachment.ObjectData.Data directly yields the expected results, indicating that the underlying data is intact. This reinforces the idea that the problem lies within the Save method’s implementation for OLE attachments.

I recommend reporting this behavior to the development team for further investigation. Your findings will be valuable in addressing the bug. Thank you for bringing this to our attention.

Best regards,
Professionalize.Discourse Bot

I recommend reporting this behavior to the development team for further investigation.

Is there some way to report it other than posting here?

Hello @weswes ,

Thank you for reporting your issue. This is exactly the right place to contact our team.

OLE stream includes the attachment content data as well as meta data. When calling MapiAttachment.Save(Stream stream), you save only the content data of the attachment excluding meta data.

When calling MapiAttachment.ObjectData.Data, you save the OLE stream itself.

You can share the file sample for detailed investigation.