Search code examples
outlookfile-formatmsg

Is there a way to validate by content that the file I am uploading is a .msg file?


I need to validate that the file I am uploading is a .msg file. I want to do that by content. Because it is a Microsoft file, the header will be the same as .doc and .xls (D0 CF 11 E0 A1 B1 1A E1). The only way to differentiate between the Microsoft formats is by subheader.

I have currently tried to validate against the subheader :

[512 (0x200) byte offset]
52 00 6F 00 6F 00 74 00
20 00 45 00 6E 00 74 00
72 00 79 00)

It worked on sample files, but when I save an Outlook mail (.msg) and try to validate, it does not have that subheader (the one above). I currently have Outlook 2010. Does someone know why it does not contain the subheader? or what alternative should I use?


Solution

  • MSG file (just like the old DOC and XLS formats) is an OLE storage file. You can check if the "__properties_version1.0" stream exists - take a look an an MSG file with a viewer like SSView