Saving RTF Text as a Message Property in RTF

In this case, you are starting with text already in RTF format—perhaps produced by a rich text editor—and you want to save this RTF text into a valid PR_RTF_COMPRESSED property on a message. You must start with a message that does not already contain a PR_RTF_COMPRESSED property. This can be either an existing message or a new message.

    To save RTF text into PR_RTF_COMPRESSED
  1. Open the destination message object with a call to the IMAPIFolder::CreateMessage method (for a new message) or IMAPIFolder::OpenEntry (for an existing message). This call returns an LPMESSAGE pointer to a message object.
  2. Create the PR_RTF_COMPRESSED message property with a call to the IMAPIProp::OpenProperty method. In this function call, pass the LPMESSAGE pointer to the destination message object, the IID_IStream interface identifier in the lpiid parameter, and the MAPI_CREATE and MAPI_MODIFY flags in the ulFlags parameter.
  3. Call the MAPI WrapCompressedRTFStream function. This call returns an unwrapped (uncompressed) stream on the PR_RTF_COMPRESSED property.
  4. Write the original RTF data to the uncompressed stream, using the IStream::CopyTo or IStream::Write methods.
  5. Call IStream::Commit on the uncompressed stream. This call saves the property in compressed format.