excel - 如何找到用户 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
解决方案
Stevie,如果我可以大胆地回答这个问题...
- 签名文件位于 -
C:\Users\username\AppData\Roaming\Microsoft\Signatures
- 他们的图像个人文件是 -
C:\Users\username\AppData\Roaming\Microsoft\Signatures\[singatureName]_files
例如:“Business_files” - 图像似乎拉入image00#.jpg索引
- 您可以尝试使用HTMLBody VS just body
- 您可以使用
NameSpace.GetDefaultFolder
获取用户的默认电子邮件帐户,从而获得该帐户的签名
也许当您使用 时NameSpace.GetDefaultFolder
,可以查看签名名称,然后可以[name]_files
获取其中可能包含的任何图像。请注意,如果您使用HTMLBody,因为这是我公司的问题,用户将在 Outlook 中的Programmatic Access Trust Center 设置中受到阻止。这会提示用户一个允许/拒绝框,他们可以在其中选择允许最多 10 分钟......仅供参考。
希望有些帮助。丹尼, ExcelVB杜德
推荐阅读
- angular - 角度动态网格瓷砖内容
- python - 使用 Flask 的应用程序工厂从应用程序中的 python 终端访问 app.models
- php - 为什么 $insert_stmt->execute() 不能正确执行
- python - 使用 numba 和 jit 在我的 gpu 上运行 python 时出错
- vb.net - 如何在 VB.Net 中调整/更改自定义创建的用户控件的位置?
- datepicker - Antdesign Blazor 日期选择器选择窗格未根据日期选择器值反映
- python - 调用散景时与 Tornado 相关的错误
- python - 可以混合精度使用对象检测 api,还是可以在构建模型之前观察/修改模型的层?
- python - 如何让所有艺术家使用 Spotify API?
- linux - 安西布尔。从 {{ item }} 循环中获取特定值