问题
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