Is there a difference between Outlook.MSG and .OFT file formats?

This question is somewhat long, but I spent hours on it to no avail. I have a code that generates an email file on a web server and allows the user to download this email and open it in Outlook. From here, they can make various changes to the email before sending them to heaps of people.

I am currently creating a .OFT file, which is basically an email template. I want to create a .MSG file, which is the actual email address. From a binary point of view, it seems that these file formats are identical. They have the same identifiers and stream properties.

My approach was to first create an empty email message in Outlook, and then just save it in the Base.oft file. In my code, I open a document and change the thread identifier __substg1.0_1013001E , which is the identifier for the body of the HTML email. Then I save the file and write it to the cyclone. It works great.

I tried the same approach with MSG format. I created an empty email, saved it as Base.msg, and changed the same stream id. If I look at the resulting file, the new body is actually saved there. However, if I open the letter, the body will remain empty.

What's even weirder, if I type the body in Outlook and save it in the base file, I can see this body under stream 0_1013001E. If I then modify this stream with a different body, I can verify that the new body is indeed saved in the file, but if I open the message in Outlook, I will see the old, original object. As if the email body is stored elsewhere in the file for the .MSG format, however, I looked through each stream and cannot find anything that looks like it could be the email body.

Maybe. MSG files are encrypted or are their bodies stored in some native binary format, unlike .OFT files? Hopefully someone has some idea about this as I was browsing the internet and mostly not found in these formats.

Update:

It seems that the .MSG format stores the body in Stream ID __substg1.0_10090102 - which is encoded in some binary form (not sure what.) If I delete the stream (or set it to one \0 , the file becomes damaged.

+4
source share
2 answers

First of all, to find more information on this and related topics, go from the raw sub-thread and google numbers to the corresponding MAPI properties. For example, 1013 is PR_HTML , and 1009 is PR_RTF_COMPRESSED . MAPI has ways to synchronize the body from one format to another.

See this article on MSDN for a good overview of all the MAPI properties associated with the content (that is, the different "streams" in the .MSG file).

To write PR_RTF_COMPRESSED, wrap the stream inside a WrapCompressedStream . On the other hand, in your specific situation, you can avoid the MAPI dependencies in your code, so perhaps you better find PR_STORE_SUPPORT_MASK and set the STORE_UNCOMPRESSED_RTF bit. This will allow you to use direct RTF in the PR_RTF_COMPRESSED subfield. Or Outlooks fancy html-wrapped-in-rtf if you feel brave.

None of this is for the faint of heart, but, seeing how you are already transferring a raw .MSG sub-thread, I assume that it will be possible.

+3
source

When it comes to format, there is no difference. the only difference is that OFT files have CLSID_TemplateMessage ({0006F046-0000-0000-C000-000000000046}) as the storage class (WriteClassStg), while MSG files use CLSID_MailMessage ({00020D0B-0000-0000-C000- 000000000046})

0
source

All Articles