共用方式為


BodyFormat Property

OlBodyFormat

OlBodyFormat can be one of the following 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.

In earlier versions of Outlook, the BodyFormat property returned the olFormatUnspecified constant for a newly created item that has not been displayed or whose BodyFormat property is not yet set programmatically. In Microsoft Office Outlook   2003, the property returns the format that is currently set in the Outlook user interface.

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.

Sub CreateHTMLMail()
'Creates a new e-mail item 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
       'Set body format to HTML
       .BodyFormat = olFormatHTML
       .HTMLBody = "<HTML><H2>The body of this message will appear in HTML.</H2><BODY>Type the message text here. </BODY></HTML>"
       .Display
    End With

End Sub

Applies to | MailItem Object | PostItem Object