ken
ken

Reputation: 399

how to declare olFormatHtml in vb

I am trying to send mail that is formated as HTML but I get an error showing that olFormatHtml is not declared. How do I declare it?

Upvotes: 0

Views: 5148

Answers (2)

Diana Tortolini
Diana Tortolini

Reputation: 230

I'm using VBA in Excel 2007 to attach a workbook to an email and format the body of that email. I just tried this suggestion and got a run-time error 438: Object doesn't support this property or method.

Instead I set .bodyformat = 2 to display email text as html, and it worked. For example....

Set Outlook = CreateObject("Outlook.Application")
Set MailItem1 = Outlook.CreateItem(0)

With MailItem1
    .BodyFormat = 2
    'sample formatting change....
    .htmlbody = "<font color = 'red'>" & "SAMPLE TEXT" & "</font><br/>"
    .display
End With

Set MailItem1 = Nothing
Set Outlook = Nothing

Upvotes: 1

ken
ken

Reputation: 399

replace olFormatHtml with Outlook.OlBodyFormat.olFormatHTML

Upvotes: 1

Related Questions