Share via


MailItem.BodyFormat Property

Outlook Developer Reference

Returns or sets an OlBodyFormat constant indicating the format of the body text. Read/write.

Syntax

expression.BodyFormat

expression   A variable that represents a MailItem object.

Remarks

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 (RTF), and HTML.

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

Example

The following Microsoft Visual Basic/Visual Basic for Applications (VBA) example creates a new MailItem object and sets the BodyFormat property to olFormatHTML. The body text of the e-mail item will now appear in HTML format.

Visual Basic for Applications
  Sub CreateHTMLMail()
    'Creates a new e-mail item and modifies its properties.
    Dim objMail As MailItem
'Create mail item
Set objMail = Application.CreateItem(olMailItem)
With objMail
   'Set body format to HTML
   .<strong class="bterm">BodyFormat</strong> = olFormatHTML
   .HTMLBody = "&lt;HTML&gt;&lt;H2&gt;The body of this message will appear in HTML.&lt;/H2&gt;&lt;BODY&gt;Type the message text here. &lt;/BODY&gt;&lt;/HTML&gt;"
   .Display
End With

End Sub

See Also