Search code examples
outlookoutlook-addin

How to check if attachment is mail message?


I'm trying to determine if attachment is mail message, i have a method for identifying if attachment is PDF from its first header bytes.

if (buffer[0] == 0x25 && buffer[1] == 0x50 && buffer[2] == 0x44 && buffer[3]== 0x46)

So first header bytes 37,80,68,70 I tried to check some email messages and saw same pattern 208(0xD0),207(0xCF),17(0x11),224(0xE0) for those messages. So my question, is it safe to assume I can always identify if the attachment is mail message from these header bytes or maybe there is a better way to check it?


Solution

  • You can just check if the attachment extension is ".msg" (if Attachment.Type == olAttachByValue) or check the Attachment.Type property to be olEmbeddedItem in case of an embedded message attachment.