我尝试插入不同的代码来获取Outlook中的默认签名,以便在生成电子邮件时显示在此代码行的末尾。有什么建议吗?
Private Sub CommandButton1_Click()
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
Dim signature As String
On Error Resume Next
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Hello," & vbCrLf & vbCrLf & "I recently reviewed a call of yours and the information that we reviewed in our coaching session is as follows:" & vbCrLf & vbCrLf & _
"Call Duration: " & Sheets("Sheet1 (13)").Range("j38").Value & vbCrLf & _
"Date: " & Sheets("Sheet1 (13)").Range("j39").Value & vbCrLf & _
"Coaching Feedback: " & Sheets("Sheet1 (13)").Range("J40").Value & vbCrLf & signature
On Error Resume Next
With xOutMail
.To = Range("D39")
.CC = Range("G39")
.BCC = ""
.Subject = "Quality Audit Coaching"
.Body = xMailBody
.Display
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
答案 0 :(得分:0)
我看到您有Dim签名变量Statement,但看不到您分配给任何对象。
如果不是HTML正文,请尝试以下操作
With xOutMail
.To = Range("D39")
.CC = Range("G39")
.BCC = ""
.Subject = "Quality Audit Coaching"
.Display
.Body = xMailBody & .Body
' .Send
End With
,如果其HTML正文将其更改为 .HTMLBody = xMailBody & .HTMLBody
或者您可以设置Dim signature variable
示例
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
With xOutMail
.Display
signature = .HTMLBody
End With
返回或设置一个表示指定项目的HTML正文的String。 HTMLBody属性应该是HTML语法字符串。读/写。
返回或设置一个字符串,表示Outlook项目的明文正文。读/写。