MailItem 属性(Outlook)MailItem.BodyFormat property (Outlook)

返回或设置一个 OlBodyFormat 常量,该常量指示正文文本的格式。Returns or sets an OlBodyFormat constant indicating the format of the body text. 读/写。Read/write.


expressionexpression. BodyFormat

expression 表示 MailItem 对象的变量。expression A variable that represents a MailItem object.


正文文本格式决定用于显示邮件文本的标准。The body text format determines the standard used to display the text of the message. Microsoft Outlook 提供了三个正文文本格式选项:纯文本、RTF 和 HTML。Microsoft Outlook provides three body text format options: Plain Text, Rich Text (RTF), and HTML.

如果将BodyFormat属性从 RTF 切换到 HTML,则所有文本格式都将丢失,反之亦然。All text formatting will be lost when the BodyFormat property is switched from RTF to HTML and vice-versa.


下面的 Microsoft Visual Basic for Applications (VBA) 示例创建一个新的 MailItem 对象,并将 BodyFormat 属性设置为 olFormatHTMLThe following Microsoft Visual Basic for Applications (VBA) example creates a new MailItem object and sets the BodyFormat property to olFormatHTML. 此时,电子邮件项目的正文文本将以 HTML 格式显示。The body text of the email item will now appear in HTML format.

Sub CreateHTMLMail() 
 'Creates a new email item and modifies its properties. 
 Dim objMail As MailItem 
 'Create mail item 
 Set objMail = Application.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>" 
 End With 
End Sub

另请参阅See also

MailItem 对象MailItem Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.