如何在电子邮件上包含签名?

时间:2019-11-01 08:40:40

标签: excel vba outlook

我有一个代码,可以向列表中的个人发送电子邮件。

我需要用户的签名显示在电子邮件的底部。我无法显示它。

下面是我的代码。

Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range

Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")

On Error GoTo Cleanup
For Each cell In Columns("M").Cells.SpecialCells(xlCellTypeConstants)
    If LCase(Cells(cell.Row, "M").Value) = "no" Then

        Set OutMail = OutApp.CreateItem(0)
        strbody = "Dear " & Cells(cell.Row, "A").Value _
          & "<br>" & "<br>" & _
          "You still have outstanding work on the Rescan Spreadsheet " & _
          " Title number:  " & Cells(cell.Row, "E").Value _
          & "<br>" & "<br>" _
          & "<A href=""\\cv-vfl-d01\dlr_office\Operational Teams\RR Scanning Team\" & _
          "Back file QA Xerox\Document Rescans\Rescans 2019"">Click here to open file location</A>"

        On Error Resume Next
        With OutMail
            .To = Cells(cell.Row, "B").Value
            .CC = "Bethany.Turner@Landregistry.Gov.uk"
            .Subject = "Re-Scan Reminder"
            .HTMLBody = strbody & .HTMLBody
            .Display
        End With
        On Error GoTo 0
        Set OutMail = Nothing
    End If
Next cell

Cleanup:
    Set OutApp = Nothing
    Application.ScreenUpdating = True
    MsgBox "Reminder Sent", vbOKOnly

End Sub

1 个答案:

答案 0 :(得分:0)

您的代码需要首先调用 Index exceeds the number of array elements (1). Error in Q9 (line 33) bar(matrix) -即Outlook将默认签名插入空电子邮件中时。

第二,不要连接两个HTML字符串-它们必须合并而不是连接:在最简​​单的情况下,搜索Display子字符串的位置,找到下一个"<body"字符(可以处理带有属性的">" HTML元素),然后插入HTML文本。

如果要发送消息而不先显示它,或者要插入任意签名,则可以使用Redemption及其RDOSignature"<body>"方法。