首页 > 解决方案 > 如何找到用户 Outlook 默认签名的文件名?

问题描述

我编写了一个 Excel 插件来使用 Outlook 发送电子邮件。我想出了一种添加用户签名的方法。不过,美中不足的是他们更改了签名的名称。

如何从 Outlook 获取用户的默认签名?

    Dim salutation As String, ourRef As String, amount As String, customerName As String, yourRef As String
    Dim totalAmount As Double

    ' salutation
    salutation = IIf(Time < 0.5, "Good morning", "Good afternoon")

    ' opening text
    totalAmount = 0
    For i = 0 To UBound(Table, 1)
        totalAmount = totalAmount + Table(i, 3)
    Next i

    body = "<!DOCTYPE html><html><body>"
    body = body & "<div style=""font-family:'Segoe UI', Calibri, Arial, Helvetica; font-size: 14px; max-width: 768px;"">"
    If bulk = True Then
        body = body & salutation & "<br /><br />We have sent you a bulk payment totaling " _
        & Format(totalAmount, "£##,##0.00") & ", to be credited to the following accounts: <br /><br />"
    Else
        body = body & salutation & "<br /><br />We have sent you the following payments: <br /><br />"
    End If

    ' table header
    body = body & "<style type='text/css'>.tftable {font-size:12px;color:#333333;width:100%;" _
        & "border-width: 1px;border-color: #9dcc7a;border-collapse: collapse;}.tftable th {font-size:12px;" _
        & "background-color:#A99D36;border-width: 1px;padding: 8px;border-style: solid;border-color: " _
        & "#9dcc7a;text-align:left;}.tftable tr {background-color:#F0EDCF;}.tftable td {font-size:12px;" _
        & "border-width: 1px;padding: 8px;border-style: solid;border-color: #9dcc7a;}"
    body = body & "</style><table class='tftable' border='1'><tr><th>Our ref</th><th>Amount</th>" _
        & "<th>Client name</th><th>Your ref</th></tr>"

    ' table body
    For i = LBound(Table, 1) To UBound(Table, 1)

        ourRef = Table(i, 1)
        amount = Table(i, 3)
        customerName = Table(i, 2)
        yourRef = Table(i, 4)

        body = body & "<tr>"
        body = body & "<td>" & ourRef & "</td>"
        body = body & "<td>" & Format(amount, "£##,##0.00") & "</td>"
        body = body & "<td>" & customerName & "</td>"
        body = body & "<td>" & yourRef & "</td>"
        body = body & "</tr>"

    Next i

    body = body & "</tbody></table>"

    ' signature
    enviro = CStr(Environ("appdata"))
    Debug.Print enviro
    Set objfso = CreateObject("Scripting.FileSystemObject")
    strSigFilePath = enviro & "\Microsoft\Signatures\"
    Debug.Print strSigFilePath
    Set objSignatureFile = objfso.opentextfile(strSigFilePath & "Standard.htm")
    strbuffer = objSignatureFile.ReadAll
    body = body & "<br/><br/>" & strbuffer
    objSignatureFile.Close

End Function

标签: excelvbaoutlook

解决方案


Stevie,如果我可以大胆地回答这个问题...

  1. 签名文件位于 -C:\Users\username\AppData\Roaming\Microsoft\Signatures
  2. 他们的图像个人文件是 -C:\Users\username\AppData\Roaming\Microsoft\Signatures\[singatureName]_files例如:“Business_files”
  3. 图像似乎拉入image00#.jpg索引
  4. 您可以尝试使用HTMLBody VS just body
  5. 您可以使用NameSpace.GetDefaultFolder获取用户的默认电子邮件帐户,从而获得该帐户的签名

也许当您使用 时NameSpace.GetDefaultFolder,可以查看签名名称,然后可以[name]_files获取其中可能包含的任何图像。请注意,如果您使用HTMLBody,因为这是我公司的问题,用户将在 Outlook 中的Programmatic Access Trust Center 设置中受到阻止。这会提示用户一个允许/拒绝框,他们可以在其中选择允许最多 10 分钟......仅供参考。

希望有些帮助。丹尼, ExcelVB杜德


推荐阅读