OL97: Working With the Message or Body of an Outlook ItemLast reviewed: March 2, 1998Article ID: Q172755 |
The information in this article applies to:
SUMMARYThis article describes how Microsoft Outlook 97 implements the Message or Notes field and answers some common questions regarding its use when customizing Outlook forms.
MORE INFORMATIONNOTE: This article discusses using fields and controls with Outlook forms and it is important to understand the difference between the two. For more information on the differences between fields and controls, please see the following article in the Microsoft Knowledge Base:
Article-ID: Q168975 Title : OL97: How to Use Fields and Controls with VBScript Working with the Message or Notes FieldThe Message field is most commonly associated with a Mail Message form and is the main portion or "body" of the message. This is a unique field because it supports Rich Text Formatting (RTF), meaning that you can change various attributes of the text, such as the font size and formatting. You can also embed objects, such as shortcuts or files into the message field. This field also exists on other Outlook forms. On a Post form, it is called the Message field, but on all other forms, it is referred to as the Notes field. When accessing this field through the Outlook object model, use the Body property of the appropriate item (ContactItem, PostItem, and so on). The following table summarizes the naming conventions:
Item Type Field Name Property Name --------- ---------- ------------- Mail Message Body Post Message Body Contact Notes Body Appointment Notes Body Meeting Request Notes Body Task Notes Body Task Request Notes Body Journal Notes Body Note* N/A Body * You cannot customize "Note" items.NOTE: The remainder of this article will use the term "Message field", but unless otherwise noted, information will apply to the Notes field as well. Each Outlook item contains one Message field to store RTF information; it is not possible to add an additional field of the same type as the Message field.
Working with the Message or Notes ControlWhen designing an Outlook form, you can use the Message control more than once on a form. However, when you insert a second Message control on a form, Outlook displays the following warning:
This form has more than one Message or Notes control. If more than one control is visible at run time, only one control works.This warning may also appear when you use the form, (at "run time") such as when you switch to a form page that contains a second Message control. Outlook controls are typically bound to MAPI fields to store the actual data and each Outlook form (or item) has only one field that supports RTF. Therefore, when you drag the Message field from the Field Chooser onto the form, it is automatically bound to the appropriate Outlook field. You cannot change this behavior. If there is more than one Message field on a form, they all display the same data since there is only one field of this type permitted for each Outlook form. However, if you change data in one of the Message fields, it does not automatically replicate to the other Message field unless you refresh the field by saving and reopening the form or setting the Body property via code. This is the main reason for the warning message mentioned above. The control used to display the Message field is built into the Outlook program and is not designed for use on non-Outlook forms. However, you can add the control to the Control Toolbox since it is a registered control on the system. Use your right mouse button to click on a blank area of the Control Toolbox and from the context-sensitive menu, click Custom Controls. "Outlook DocSite OLE Control." should appear in the list of available controls. This is the control used to display the Message field. NOTE: The other Outlook-specific control is the "Outlook Recipient Collection Edit OLE Control," which is used for the To and From fields on a Mail Message. It is specifically designed to resolve e-mail addresses and provide other functionality specific to fields containing e-mail addresses, such as handling copy and paste between fields of this type.
Working with the Body PropertyAlthough you can use Rich Text Formatting through the user interface, when you use the Body property from Microsoft Visual Basic Script (VBScript) or Microsoft Visual Basic for Applications automation code, all of the text formatting is lost. This is because the data type of the Body field is text, so it behaves no differently than other types of controls, such as a label or textbox. You can write VBScript code that will retrieve the Body of the message and add text to the beginning of it; however, you cannot preserve the text formatting. Use the Body property to retrieve the text that is in the body. Programmatically add extra text to the beginning of the body (Item.Body = "Added text" & Item.Body). When VBScript replaces the text in the field, the text is unformatted and any previous formatting is lost. There is no workaround to this limitation. For more information on manipulating text within a form's Message field, please see the following article in the Microsoft Knowledge Base:
Article-ID: Q162995 Title : OL97: VBScript Cannot Access Characters in the Body Property REFERENCESFor more information about creating solutions with Microsoft Outlook 97, please see the following articles in the Microsoft Knowledge Base:
Article-ID: Q166368 Title : OL97: How to Get Help Programming with Outlook Article-ID: Q170783 Title : OL97: Q&A: Questions about Customizing or Programming Outlook |
Additional query words: OutSol OutSol97
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |