Reputation: 31750
I have an email template which has html formatting and place holders to swap out with real values.
In Excel I load the email via the Outlook CreateItemFromTemplate method. If at this point I save the email formatting is preserved.
If I perform a replace on the body most of the formatting is stripped out:
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItemFromTemplate("template.oft") ' <- has lots of html formatting
With OutMail
.Body = Replace(.Body, "#recipient#", "Some other value") ' <- Strips out most formatting!!
.Save ' <- this works fine without the line above.
End With
Upvotes: 2
Views: 14535
Reputation: 31750
Thanks to this post : https://stackoverflow.com/a/8473313/569662
My problem was you have to use .HTMLBody
rather than .Body
:
.HTMLBody = Replace(.HTMLBody, "#recipient#", "Some other value")
Upvotes: 5