我想知道当您输入 Outlook 2010 的收件人地址时,是否可以自动检测此地址并相应地更改签名? 只是一个一般性问题。
我有同样的问题,到目前为止还没有找到答案。作为一个不错的解决方法,我已经成功地使用了此处提供的解决方案:https://superuser.com/a/228633/74819。最后,您会在工具栏上看到一个按钮,允许您使用自定义的收件人地址和您选择的预定义正文文本(包括签名)创建新消息。
现在我实际上发现这种方法比我正在寻找的方法更好,因为它更可预测。如果签名(以及邮件正文)根据收件人列表而更改,您将失去对文本的控制。此外,使用您自己的工具,您可以设置的不仅仅是签名。
您是在寻找执行此操作的设置还是愿意使用宏? 如果您愿意使用宏,请参阅下文并回复问题。
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