2

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
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
tom redfern
  • 30,562
  • 14
  • 91
  • 126

1 Answers1

5

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") 
Community
  • 1
  • 1
tom redfern
  • 30,562
  • 14
  • 91
  • 126