Outlook 2007:如何以编程方式根据电子邮件收件人选择签名(收件人:抄送:密件抄送:等)

发布于 2024-10-13 06:02:26 字数 223 浏览 5 评论 0原文

该方法与我无关。无论它是宏,还是在发送电子邮件时以某种方式自动触发。
我想知道outlook是否有办法自动根据收件人分配签名。

  • 必须与 Outlook 2007 配合使用。如果存在替代方法,可以添加它们,并引用其适用的版本。 2007 年我的很多宏都必须重写。
  • 方法并不重要,只要除了常规 UI 使用来发送电子邮件之外不涉及用户交互即可。

谢谢。

The method does not concern me. Whether it is a macro, or somehow automatically fires as the email is sent.
I want to know if there is a way for outlook to automatically assign a signature based on the recipient.

  • Must work with Outlook 2007. If alternate methods exist, they can be added, referencing which version it works on. A lot of my macros had to be rewritten for 2007.
  • Method is not important, as long as it doesn't involve user interaction other than regular UI usage to send an email.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜深人未静 2024-10-20 06:02:26

基于这里的代码 http://www.rondebruin.nl/win/s1/ Outlook/signature.htm

您可以将其设置为从 Application_ItemSend 调用,但这可能会带来麻烦。

Sub With_Variable_Signature()
Dim itm As mailItem
Dim StrSignature As String
Dim sPath As String
Dim recip As Recipient

Set itm = ActiveInspector.currentItem

sPath = Environ("appdata") & "\Microsoft\Signatures\defaultSig.htm"

For Each recip In itm.Recipients
    Debug.Print recip.name
    If recip.name = "somebody"  And recip.type = olTo Then ' or = olcc or = olbcc
        sPath = Environ("appdata") & "\Microsoft\Signatures\customizedSig.htm"
        Exit For
    End If
Next

If Dir(sPath) <> "" Then
    StrSignature = GetBoiler(sPath)
Else
    StrSignature = ""
End If

With itm
    .HTMLBody = .HTMLBody & vbNewLine & vbNewLine & StrSignature
End With  

Set itm = Nothing

End Sub

Function GetBoiler(ByVal sFile As String) As String
'Dick Kusleika
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function

Based on code from here http://www.rondebruin.nl/win/s1/outlook/signature.htm

You can set it up to be called from Application_ItemSend but that is probably asking for trouble.

Sub With_Variable_Signature()
Dim itm As mailItem
Dim StrSignature As String
Dim sPath As String
Dim recip As Recipient

Set itm = ActiveInspector.currentItem

sPath = Environ("appdata") & "\Microsoft\Signatures\defaultSig.htm"

For Each recip In itm.Recipients
    Debug.Print recip.name
    If recip.name = "somebody"  And recip.type = olTo Then ' or = olcc or = olbcc
        sPath = Environ("appdata") & "\Microsoft\Signatures\customizedSig.htm"
        Exit For
    End If
Next

If Dir(sPath) <> "" Then
    StrSignature = GetBoiler(sPath)
Else
    StrSignature = ""
End If

With itm
    .HTMLBody = .HTMLBody & vbNewLine & vbNewLine & StrSignature
End With  

Set itm = Nothing

End Sub

Function GetBoiler(ByVal sFile As String) As String
'Dick Kusleika
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文