HTML in messages that touch Exchange - how to retrieve?

Dec 29, 2010 at 1:48 AM

It seems that any message that is touched by Exchange no longer has an HTML body. Saving a PST file that comes from a user mailbox on an exchange server results in messages that contain compressed RTF, which includes embedded HTML, but no way as far as I can see to directly retrieve the HTML that was on the wire before it hit the Exchange server. It seems that I need some way to decompress, then interpret, the compressed RTF. Is there anything anyone can suggest to do this conversion?

Dec 29, 2010 at 3:15 AM

Yes, sometimes the HTML body simply isn't present in the PST file. Outlook, Exchange, etc.. all have logic (called "Best Body" logic) to convert existing body formats (such as RTF) into other body formats (like HTML) when the client requests the body of a specific format. In these cases, you'll basically have to replicate this functionality by using some RTF library to ready and interpret the compressed RTF streams.

Jan 1, 2011 at 12:29 AM

I was afraid of that. Well, if that's what I need to do, that is what I will do.

Jan 1, 2011 at 4:02 AM

If the HTML body isn't available, it might be easier to fallback on the plaintext version if present rather than trying to convert the RTF body.

Jan 1, 2011 at 4:58 AM

There are reasons that our clients want the formatted version. The plaintext will do for some content search, but we are going to have to produce the rich text somehow.

May 27, 2011 at 4:07 AM

The retrieval of the original format from the RTF isn't that hard - I've done it for the Thunderbird Outlook import module ( The RTF format was extended by MS to be able to include information both of the original format (plaintext or HTML) and the original HTML tags (if any). Personally I found that it's safer to _always_ use RTF version, even if the body is originally plain/html and the corresponding property exists. But the obstacle may be in the decompression of the RTF. In Outlook MAPI, it's done with a call to WrapCompressedRTFStream (or WrapCompressedRTFStreamEx from msmapi32.dll). Is there any method to do this in pstsdk? Or maybe some hint how to implement this?