由于我是VBA的新手,所以我试图构建代码以通过带签名的Outlook发送电子邮件。但是,当我运行以下代码时,它仅向我显示签名(不显示正文)。
当我使用“ F8”进行检查时,可以清楚地看到我的身体出现,然后签名将其覆盖。如何解决此问题?
regexp
答案 0 :(得分:1)
您需要将.body
更改为.HTMLBody
,请参考以下代码:
Option Explicit
Sub SendEmailwithsign()
Dim objoutApp As Object, objoutmail As Object
Dim strbody As String, strSig As String
Set objoutApp = CreateObject("outlook.Application")
Set objoutmail = objoutApp.CreateItem(0)
On Error Resume Next
With objoutmail
.To = "emailAddress"
.CC = ""
.Subject = "Test mail"
strSig = .Environ("appdata") & "Microsoft\Signatures\default.txt"
strbody = "Hello"
.HTMLBody = "<p>"+ strbody +"</p>" & strSig 'with this step Body part does not appear but only the signature'
.Recipients.ResolveAll
.Display 'body appears until this point'
End With
On Error GoTo 0
Set objoutmail = Nothing
Set objoutApp = Nothing
End Sub
引用来自: