我有一个电子邮件模板,它具有 html 格式和占位符,可以用实际值换出。
在 Excel 中,我通过 Outlook CreateItemFromTemplate 方法加载电子邮件。如果此时我保存电子邮件格式将被保留。
如果我在正文上执行替换,则大部分格式都会被删除:
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