Supporting Formatted Text in Incoming Messages: Client Responsibilities
Last modified: January 16, 2009
Applies to: Office 2010 | Outlook 2010 | Visual Studio
As messages are transferred between messaging systems, the MAPI spooler makes sure that the rich text formatting remains synchronized with the message text. The MAPI spooler calls the RTFSync function from within a wrapped version of the message that it passes to the transport provider. The transport provider saves the changes made to the message by calling the IMAPIProp::SaveChanges method and then routes it to the new recipient.
When the recipient's RTF-aware client application opens the message to display the text, it must synchronize the text with the formatting and open either PR_RTF_COMPRESSED (PidTagRtfCompressed) or PR_BODY (PidTagBody), depending on which property is available.
To open a message, RTF-aware clients
Call RTFSync to synchronize the message text with the formatting if the message store is not RTF-aware. The RTF_SYNC_BODY_CHANGED flag should be passed in the ulFlags parameter if the PR_RTF_IN_SYNC (PidTagRtfInSync) property is missing or set to FALSE. Clients working with RTF-aware message stores need not make the RTFSync call because the message store takes care of it.
Call IMAPIProp::SaveChanges if the message text has been updated.
Call IMAPIProp::OpenProperty to open the PR_RTF_COMPRESSED property. If PR_RTF_COMPRESSED is not available, you should open the PR_BODY property instead to display the message content.
Call the WrapCompressedRTFStream function to create an uncompressed version of the compressed RTF data, if available.
Display the uncompressed RTF data or the plain text data to the user.
RTFSync returns a Boolean value that indicates whether or not the message has been updated. If this value returns TRUE, call SaveChanges at some point to make the update permanent. The call does not have to be made immediately after RTFSync returns.
Because so many components handle the formatted text before you receive it, there is the possibility of corruption. This corruption could come from the message store provider, a third party application, a gateway, or a transmission error.