【问题标题】:How to include signature on email?如何在电子邮件中包含签名?
【发布时间】:2022-05-01 11:06:41
【问题描述】:

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

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

下面是我的代码。

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

【问题讨论】:

标签: excel vba outlook


【解决方案1】:

您的代码需要首先调用Display - 即 Outlook 将默认签名插入空电子邮件时。

其次,不要连接两个 HTML 字符串 - 它们必须合并,而不是连接:在最简​​单的情况下,搜索 "&lt;body" 子字符串的位置,找到下一个出现的 "&gt;" 字符(这要小心"&lt;body&gt;" 带有属性的 HTML 元素),然后插入您的 HTML 文本。

如果你想在不先显示的情况下发送消息,或者如果你想插入任意签名,你可以使用Redemption(我是它的作者)和它的RDOSignature.ApplyTo方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-19
    • 2011-06-22
    • 2016-02-03
    • 2018-07-24
    • 1970-01-01
    • 2023-03-18
    相关资源
    最近更新 更多