Thank you for sharing the MSG file with us.
I have analyzed the 13315453897600986597.msg
file and it showed that the 'stream length' is 62542, but the 'byte count' specified by the PidTagAttachDataBinary
property is 62084.
I have extracted the data from the stream and it seems the 62542 value is correct (the 62084 length would produce incomplete PDF file).
Also, if I save the attachment from the Outlook, the saved file is 62542 bytes length.
However the MS-OXMSG 2.4.2.2. specification for variable length data clearly says:
Size MUST be equal to the size of the stream where the value of the property represented by this entry is stored.
If you manipulate the attachment data yourself, please update the corresponding property 'Size'
('byte count') value appropriately to produce valid MSG file.
What are you using for updating attachment data?
We have the MsgMessage
class, which can do this task correctly. It is available on our labs page https://www.rebex.net/msg/.
However, we plan to include the MsgMessage
class in our main product.
To update attachment data you can just do:
var msg = new MsgMessage();
msg.Load(path);
msg.Attachments[0].Properties.SetValue<byte[]>(MsgPropertyTag.AttachDataBinary, newContentBytes);
msg.Save(path);