Skip to content

BodyFormat


Overview

The BodyFormat property determines the formatting type of the email message body, specifying how the text is represented and rendered.

Syntax

vba
' To set the formatType
mailItem.BodyFormat = formatType

' To get the formatType
formatType = mailItem.BodyFormat

Return Value

A olBodyFormat constant indicating the type of formatting to be applied to the MailItem.

Example

vba
Sub BodyFormatExample()
    Dim app As New nlsMailer.Application
    Dim mailItem As Object

    ' Create a new mail item
    Set mailItem = app.CreateItem(olMailItem)

    ' Set plain text body
    mailItem.Body = "Simple plain text message"
    ' Body format is automatically set to olFormatPlain
    Debug.Print mailItem.BodyFormat ' Outputs: olFormatPlain

    ' Set HTML body
    mailItem.HTMLBody = "<html><body><h1>HTML Message</h1></body></html>"
    ' Body format is automatically set to olFormatHTML
    Debug.Print mailItem.BodyFormat ' Outputs: olFormatHTML

    ' Manually set body format
    mailItem.BodyFormat = olFormatRichText
End Sub