Keep formatting of Outlook signature when creating mail

陌路散爱 提交于 2019-12-13 01:27:05

问题


I copied the whole block of code from How can I use Outlook to send email to multiple recipients in Excel VBA and added a signature at the end of the email message.

With OutMail
    .Display
End With
    Signature = OutMail.Body
With OutMail
    .To = sTo
    .CC = sCC
    .BCC = ""
    .Subject = Worksheets("MassEmail").Range("A2") & " WW" & Worksheets("MassEmail").Range("B1")
    sHTML = "<HTML><BODY><FONT face=""Calibri, Arial"">"
    sHTML = sHTML & "<p style=""font-size:11pt"">Hi,</p>"
    sHTML = sHTML & "<p style=""font-size:11pt"">Here is the RMA list WW" & Worksheets("MassEmail").Range("B1") & ".  Please review.</p>"
    sHTML = sHTML & "<pre style=""font-size:11pt;font-family:Calibri,Arial"">     Total: </pre>"
    .HTMLBody = sHTML & Signature
    .HTMLBody = .HTMLBody & "</FONT></BODY></HTML>"
End With

This is how the signature should look.

The output is ok except the signature.

I tried changing .htmlbody to .body, but results are worse.

The output with .body.

I'm using Excel/Outlook 2007.


回答1:


you need to set the format of the messaage to RichText or HTMLFormat

something like olFormatHTML or olFormatRichText

then use MailItem.HTMLBody="...."

there is more information on VBA MVP Legend Ron De Bruin's website

Example Code for sending mail from Excel



来源:https://stackoverflow.com/questions/15758300/keep-formatting-of-outlook-signature-when-creating-mail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!