创建邮件时保持Outlook签名的格式

时间:2013-04-02 07:17:09

标签: excel vba email outlook-2007

我从How can I use Outlook to send email to multiple recipients in Excel VBA复制了整个代码块,并在电子邮件的末尾添加了签名。

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

这是签名的外观 Original signature

除签名外,输出正常。 HTMLbody

我尝试将.htmlbody改为.body,但结果更糟。

.body的输出。 Body

我正在使用Excel / Outlook 2007。

1 个答案:

答案 0 :(得分:0)

您需要将消息的格式设置为RichText或HTMLFormat

类似 olFormatHTML olFormatRichText

然后使用 MailItem.HTMLBody =“....”

有关 VBA MVP传奇Ron De Bruin 网站的更多信息

Example Code for sending mail from Excel