繁体   English   中英

VBA 展望签名

[英]VBA Outlook Signature

我尝试插入不同的代码来获取 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

我看到你有 Dim 签名变量 Statement 但我没有看到你分配给任何对象。

如果它不是 HTML 正文,请尝试以下操作

With xOutMail
    .To = Range("D39")
    .CC = Range("G39")
    .BCC = ""
    .Subject = "Quality Audit Coaching"
    .Display
    .Body = xMailBody & .Body
   ' .Send
End With

如果它的 HTML Body 然后将其更改为.HTMLBody = xMailBody & .HTMLBody

或者您可以设置Dim signature variable

例子

Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)

With xOutMail
    .Display
     signature = .HTMLBody
End With

MSDN HTMLBody 属性

返回或设置表示指定项的 HTML 正文的字符串。 HTMLBody 属性应该是 HTML 语法字符串。 读/写。

MSDN .Body 属性

返回或设置一个字符串,表示 Outlook 项目的明文正文。 读/写。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM