VBA HTML email formatting

TheWennerWoman

Active Member
Joined
Aug 1, 2019
Messages
301
Office Version
  1. 365
Platform
  1. Windows
I have a text box on a sheet which is the body of an email that gets generated.

It's formatted properly (ALT + ENTER to create new paragraphs) and the emails look fine.

I've been asked to include a hyperlink in the body so
VBA Code:
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
    With OutMail
        .SentOnBehalfOfName = Email_address_from
        .To = Sheet2.Cells(i, 4).Value
        .subject = subject
        .body = body '<<<<<< changed this to .HTMLbody
        .Send
    End With

However, the email now loses all paragraphs and just displays as several sentences strung together.

How do I get .HTMLbody to recognise paragraphs?

Thanks in advance as always.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Use pure html for the body text and you should have no problem. A new paragraph tag is <P>.
W3 schools has lots of info on writing html. They push cascading style sheets these days, but you should be able to find plenty of html examples. You can even test your code on their site before implementing it.
 
Upvote 1
Solution
I just noticed your posted code uses .body but you will need to use .HtmlBody

Thanks for the recognition & I hope you get it working!
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,173
Members
452,615
Latest member
bogeys2birdies

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
Back
Top