【发布时间】:2019-10-08 00:06:29
【问题描述】:
我的代码可以打开一封带有邮件正文内容的 Outlook 电子邮件,但没有一种格式有效。
在电子邮件中,它只是显示为一个字符串,例如:
<strong>Bold this part</strong>Unbold this text
<b>This text bold</b>Test
我一直在这里寻找答案,但没有一个有效。
到目前为止,这是我的代码:
Sub Send_email()
Dim OutApp As Object
Dim OutMail As Object
Dim MailBody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
MailBody = "First line of email" & vbNewLine & vbNewLine & _
"<strong>Bold this part</strong>" & "Unbold this text" & vbNewLine & _
"<b>This text bold</b>" & "Test"
On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "Email Subject"
.Body = MailBody
.Display 'or use .Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
【问题讨论】:
-
.HTMLBody而不是.Body。有关更多信息,请参阅docs。