vba - 如何添加 HTMLBody 签名?
问题描述
我需要在生成的 Outlook 电子邮件末尾添加我的签名。
我将我的 ( .HTMLBody = msg
) 更改为 ( .HTMLBody = msg & .HTMLBody
)。这让我的签名显示出来,但我的消息文本消失了。当我.HTMLBody
在最后删除并使用我的原始代码时,我的文本显示格式正确但没有签名。
Sub Email()
Dim OutApp As Object
Dim OutMail As Object
Dim Path As String
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
msg = "<p>Hello World,</p><br>"
On Error Resume Next
With OutMail
.Display
.To = ""
.CC = ""
.BCC = ""
.Subject = "Fruits Stock " & Path
.HTMLBody = msg & "Hello World" & .HTMLBody
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
解决方案
你用谷歌搜索过MailItem.HTMLBody
吗?
它在这里显示了一个示例:
Sub CreateHTMLMail()
'Creates a new email item and modifies its properties.
Dim objMail As Outlook.MailItem
'Create email item
Set objMail = Application.CreateItem(olMailItem)
With objMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.HTMLBody = _
"<HTML><BODY>Enter the message text here. </BODY></HTML>"
.Display
End With
End Sub
如果您希望您的电子邮件采用 HTMl 格式,您需要设置一个标志:
.BodyFormat = olFormatHTML
查找MailItem.BodyFormat
属性。
推荐阅读
- javascript - 如何在 AngularJS 中访问请求的 HTTP 标头
- aem - AEM 中数字资产的 URL 映射
- jquery - jsPDF-AutoTable:在页面上显示多个页脚,并排绘制多个水平表格
- c++ - 访问数组时的加扰数[10000]
- winapi - 如何从像素缓冲区创建 Win32 HBITMAP
- java - 无法解决:com.github 受影响的模块
- angular - Angular 7 变更检测:NgZone.onMicrotaskEmpty 的问题
- airflow - 气流调度程序无法拾取预定的 DAG,但在手动触发时运行
- python - imread() 得到了一个意外的关键字参数“flatten”
- objective-c - Sparkle 与 mac app cocoa 中的安全性集成