基于收件人的Outlook 2010更改签名

基于收件人的Outlook 2010更改签名,outlook,ms-office,signatures,Outlook,Ms Office,Signatures,我想知道,当您为Outlook 2010输入收件人地址时,是否可以自动检测此地址并相应地更改签名?只是一个一般性的问题。您是在寻找一个设置来实现这一点,还是愿意使用宏?如果您愿意使用宏,请参阅下面的内容并回答问题 Public WithEvents goInspectors As Outlook.Inspectors Public WithEvents myMailItem As Outlook.MailItem Private Sub Application_Startup() In

我想知道,当您为Outlook 2010输入收件人地址时,是否可以自动检测此地址并相应地更改签名?只是一个一般性的问题。

您是在寻找一个设置来实现这一点,还是愿意使用宏?如果您愿意使用宏,请参阅下面的内容并回答问题

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)为红色。知道我做错了什么吗?在VBA环境中使用这个。在Outlook中,按Alt-F11并将其粘贴到此Outlook会话中。所有这些都应该从这里开始。@phillip3196772您已经写了(oldSignature=“恭敬地,&vbCrLf&vbCrLf&“Phillip”),但是我如何解释在Outlook的“标准签名”部分制作的预制作签名(例如称为“标准”)呢?只需重新创建
oldSignature
,以使预制作的“标准”签名中的文本相等。如果这不合理,发布一封显示签名的空白电子邮件截图,我可以提供帮助。@phillip3196772-如果“标准”签名是图像而不是文本怎么办?那么,我是否可以只参考图像的位置?