Outlook 2010根据收件人更改签名

7
我想知道在Outlook 2010中是否有可能自动检测收件人地址并相应地更改签名?这只是一个一般性的问题。
2个回答

3

我曾经有同样的问题,但到目前为止还没有找到答案。作为一个很好的解决方案,我成功地使用了这里提供的解决方案:https://superuser.com/a/228633/74819。最终,您可以在工具栏上获得一个按钮,允许您创建一个新消息,其中包括指定的收件人和预定义的正文内容(包括签名)。

现在,我实际上认为这种方法比我所寻找的更好,因为它更可预测。如果签名(因此是邮件正文)基于收件人列表而更改,那么您将失去对文本的控制。此外,使用自己的工具,您可以设置不止一个签名。


2

您是在寻找设置来实现此功能,还是愿意使用宏?如果您愿意使用宏,请参考下面的内容,并回复您可能遇到的问题。

Public WithEvents goInspectors As Outlook.Inspectors
Public WithEvents myMailItem As Outlook.MailItem

Private Sub Application_Startup()
    Initialize_Inspector
End Sub

Private Sub Initialize_Inspector()
    Set goInspectors = Outlook.Application.Inspectors
End Sub

Private Sub goInspectors_NewInspector(ByVal Inspector As Inspector)
    If Inspector.currentItem.Class = olMail Then
        Set myMailItem = Inspector.currentItem
    End If
End Sub

Private Sub myMailItem_PropertyChange(ByVal Name As String)

    'The variable below should be modified for your situation.
    'If you are in an Exchange environment, then you can use "last name, firstname"(caps-sensitive).
    'If the the recipient is not in Outlook's address list, use "person@email.com"
    customSignatureFor = "Lastname, Firstname"

    'Use vbCrLf to account for enter/returns
    oldSignature = "Respectfully," & vbCrLf & vbCrLf & "Phillip"
    newSignature = "v/r," & vbcrlf & "Phil"

    If Name = "To" Then
        For i = 1 To myMailItem.Recipients.count
            If InStr(myMailItem.Recipients(i), customSignatureFor) > 0 Then
                tempstring = Replace(myMailItem.Body, oldSignature, newSignature)
                myMailItem.Body = tempstring
            End If
        Next
    End If
    End Sub

@phillip3196772 - 谢谢你的回复,但是当我将这个代码复制粘贴到一个空白宏中时,编译器会报错,提示“只有在对象模块中才有效”,并且前两行(即public)显示为红色。你有什么想法吗? - Often Right
在VBA环境中使用此代码。从Outlook中,按下Alt-F11,然后将其粘贴到thisOutlooksession。一切都应该可以从那里正常工作。 - phillip3196772
@phillip3196772 你写了(oldSignature = "Respectfully," & vbCrLf & vbCrLf & "Phillip"),但是如果我要考虑在Outlook的标准签名部分创建的预设签名(例如一个叫做“standard”的签名),该怎么办呢? - Often Right
只需重新创建oldSignature以等于预先制作的“标准”签名中的文本即可。如果不清楚,请发布一个显示签名的空白电子邮件截图,我可以提供帮助。 - phillip3196772
@phillip3196772 - 如果“标准”签名是图像而不是文本,那我是不是只需要引用图像的位置呢? - Often Right
我以前从未动态切换过签名图像,但是这个示例展示了如何通过对你的特定情况进行一些修改来实现它。 http://www.systemnetmail.com/faq/4.4.aspx - phillip3196772

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接