很抱歉,如果这是一个愚蠢的小学生问题。第一次将脚趾浸入水中,请保持温柔。
我编写了一个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
结束功能
答案 0 :(得分:1)
Stevie,如果我敢于回答这个问题...
C:\Users\username\AppData\Roaming\Microsoft\Signatures
C:\Users\username\AppData\Roaming\Microsoft\Signatures\[singatureName]_files
例如:“ Business_files” NameSpace.GetDefaultFolder
来获取用户的默认电子邮件帐户,从而获得该帐户的签名也许当您使用NameSpace.GetDefaultFolder
时,可以查看签名名称,然后可以执行[name]_files
来获取其中可能有的任何图像。请注意,如果您使用 HTMLBody ,因为这是我公司的问题,则用户将无法访问 Programmatic Access 信任中心设置在Outlook中。这将提示用户一个“允许/拒绝”框,他们可以在其中选择“允许最多10分钟...仅供参考”。
希望其中一些帮助。 丹尼 ExcelVBADude
答案 1 :(得分:0)
您可以从注册表中读取“新签名”和“回复转发签名”二进制值:
HKEY_CURRENT_USER \ Software \ Microsoft \ Office \ 15.0 \ Outlook \ Profiles [profileName] \ 9375CFF0413111d3B88A00104B2A6676 [accountNO] \