Excel vba - Outlook签名的格式化已经过去了 [英] Excel vba - Formatting of Outlook signature is gone

查看:491
本文介绍了Excel vba - Outlook签名的格式化已经过去了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我指的是这篇文章提供的答案


I'm referring to the answer provided from this post How can I use Outlook to send email to multiple recipients in Excel VBA.

I'm using Excel/Outlook 2007. I copied the whole block of code and added a signature at the end of the email message. The output in the email is ok except the signature. I tried to change .htmlbody to .body in vba, but it results it even worse. Anyone can help?

Thank you.

This is how the signature looks like.

The output when I run the macro (with .htmlbody).

The output when I run the macro (with .body).

My code:

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

解决方案

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

这篇关于Excel vba - Outlook签名的格式化已经过去了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆