MailItem.HTMLBody Property

Outlook Developer Reference

Returns or sets a String representing the HTML body of the specified item. Read/write.

Syntax

expression.HTMLBody

expression   A variable that represents a MailItem object.

Remarks

The HTMLBody property should be an HTML syntax string.

Setting the HTMLBody property sets the EditorType property of the item's Inspector to olEditorHTML.

Setting the HTMLBody property will always update the Body property immediately.

Example

The following 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 Outlook.MailItem
'Create e-mail item
Set objMail = Application.CreateItem(olMailItem)
With objMail
    'Set body format to HTML
    .BodyFormat = olFormatHTML
    .<strong class="bterm">HTMLBody</strong> = _
        "&lt;HTML&gt;&lt;BODY&gt;Enter the message text here. &lt;/BODY&gt;&lt;/HTML&gt;"
    .Display
End With

End Sub

See Also