Formatted Text

Formatted text is text that can specify its own attributes, such as typeface, style, size, and color, and perhaps other features, such as paragraph spacing, bullets, and numbering. Text that is not formatted is called plain text. MAPI supports both plain text and formatted text.

Programs that wish to exchange formatted text must agree on how the formatting information is to be communicated between them. MAPI clients typically use Microsoft’s RTF specification for this purpose. RTF encodes formatting information as plain-text keywords mixed in with the actual text of the message. For example, a formatted sentence such as, “I like to use different styles,” can be encoded into plain text as:

{\rtf1\ansi\ansicpg1252\deff0\deftab720{\fonttbl{\f0\fswissMS Sans Serif;}{\f1\
froman\fcharset2 Symbol;}{\f2\froman Times New Roman;}{\f3\fswiss MS Sans 
Serif;}}{\colortbl\red0\green0\blue0;}\deflang1033\pard\plain\f2\fs20 Ilike to 
use \plain\f2\fs20\i different\plain\f2\ fs20  \plain\f2\
fs20\b styles\plain\f2\fs20 ,\plain\f3\fs17 \par }

(The line breaks in this example are for printing this book only. The actual RTF for this example contained no line breaks.)

It isn’t necessary to learn RTF in order to use it in a messaging application. Visual Basic provides a very flexible RichTextBox control. The RichTextBox control has all the features of a standard TextBox control, plus the ability to work with formatted text. The control has methods for selecting portions of the text and ...

Get CDO & MAPI Programming with Visual Basic: now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.