VBA not formatting email correctly

ccordner

Active Member
Joined
Apr 28, 2010
Messages
348
I'm sending an email using VBA with the following code:

VBA Code:
Sub CreateEmail()

'Find the last row of the mailing list
lngLastRow = Sheets("Interface").Cells(Rows.Count, 4).End(xlUp).Row

For lngRowCount = 25 To lngLastRow
     'Create and declare an Outlook Application Object
Set objol = New Outlook.Application
Set objmail = objol.CreateItem(olMailItem)
    With objmail
        .To = Sheets("Interface").Cells(lngRowCount, 4)
'        .ReplyRecipients = "*****@gmail.com"
        .Subject = "Test Subject"
        .BodyFormat = olFormatHTML
        .Body = "Testing the  <h2>HTML</h2> test"
        .NoAging = True
'        .Attachments.Add Folder
        .send
    End With
'Clear the objects after use
Set objmail = Nothing
Set objol = Nothing
Next

End Sub

However, instead of interpreting the body as HTML, it just displays the HTML tags - both in the 'Sent Items' folder of Outlook and on my mobile phone browser. Have I missed something?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

VBE313

Well-known Member
Joined
Mar 22, 2019
Messages
686
Office Version
  1. 365
Platform
  1. Windows
Change .Body to .HTMLBody
 

Forum statistics

Threads
1,144,671
Messages
5,725,690
Members
422,635
Latest member
crisis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top