BodyFormat Property

Microsoft Outlook Visual Basic

Show All

BodyFormat Property

       

Returns or sets an OlBodyFormat constant indicating the format of the body text. The body text format determines the standard used to display the text of the message. Microsoft Outlook provides three body text format options: Plain Text, Rich Text and HTML. Read/write OlBodyFormat.

OlBodyFormat can be one of these OlBodyFormat constants.
olFormatHTML
olFormatPlain
olFormatRichText
olFormatUnspecified

expression.BodyFormat

expression   Required. An expression that returns one of the objects in the Applies To list.

Remarks

All text formatting will be lost when the BodyFormat property is switched from RTF to HTML and vice-versa.

The property can not be set to olFormatUnspecified, however it will return olFormatUnspecified if the item has not yet been displayed.

Example

The following example creates a new MailItem object and sets the BodyFormat property to olFormatRichText. The Body text of the Mail item will now appear in Rich Text format.


Sub NewMail()
'Creates a new Mailitem and modifies its properties

    Dim olApp As Outlook.Application
    Dim objMail As MailItem
    Set olApp = Outlook.Application
    'Create mail item
    Set objMail = olApp.CreateItem(olMailItem)

    With objMail
       .DownloadState = olHeaderOnly
       'Set body format to Rich Text
       .BodyFormat = olFormatRichText
       .Display
    End With

End Sub