如何在Outlook中回复或转发时为多个电子邮件帐户添加不同的签名?
从教程:Outlook中的电子邮件签名,您应该知道如何在Outlook中创建签名。然而,在创建新签名后,如果您希望在回复或转发邮件时添加该签名,则必须通过在邮件窗口中选择“签名 > 已创建的签名”来手动添加已创建的签名。
当然,您可以通过点击“签名 > 签名”,并为特定电子邮件帐户选择一个签名(如下所示),让Outlook在您回复或转发新邮件时自动添加签名。

但是,如果您有许多电子邮件帐户,并希望批量为您的多个帐户添加不同的签名该怎么办呢?在本教程中,我将介绍一种VBA方法,帮助您轻松完成此任务。
在Outlook中回复或转发时为多个电子邮件帐户添加不同的签名
1. 在您的Outlook中,按 Alt + F11 键打开Microsoft Visual Basic for Applications窗口。
2. 在Microsoft Visual Basic for Applications窗口中,双击项目窗格中的ThisOutlookSession,并将以下VBA代码复制到ThisOutlookSession(代码)窗口中。见截图:

VBA代码:在Outlook中创建新邮件时为多个电子邮件帐户添加不同的签名 - ThisOutlookSession
Public WithEvents GInspectors As Inspectors
Public WithEvents GExplorer As Explorer
Private Sub Application_Startup()
Set GInspectors = Application.Inspectors
Set GExplorer = Application.ActiveExplorer
End Sub
Private Sub GExplorer_InlineResponse(ByVal Item As Object)
‘Update by ExtendOffice
Dim xMail As MailItem
On Error Resume Next
EndTimer
If Item.Class = olMail Then
Set xMail = Item
Set GInspector = Nothing
Set GInspector = xMail.GetInspector
StartTimer
End If
End Sub
Private Sub GInspectors_NewInspector(ByVal Inspector As Inspector)
On Error Resume Next
EndTimer
Set GInspector = Nothing
Set GInspector = Inspector
StartTimer
End Sub
3. 在Microsoft Visual Basic for Applications窗口中,点击“插入 > 模块”。然后将以下VBA代码复制到模块窗口中。

VBA代码:在Outlook中回复或转发时为多个电子邮件帐户添加不同的签名 - 模块
Public Declare PtrSafe Function SetTimer Lib "user32" (ByVal HWnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As LongPtr) As Long
Public Declare PtrSafe Function KillTimer Lib "user32" (ByVal HWnd As Long, ByVal nIDEvent As Long) As Long
Public TimerID As Long
Public GInspector As Inspector
Sub StartTimer()
On Error Resume Next
TimerID = SetTimer(0&, 0&, 1000&, AddressOf TimerProc)
End Sub
Sub EndTimer()
On Error Resume Next
KillTimer 0&, TimerID
End Sub
Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, ByVal nIDEvent As Long, ByVal dwTimer As Long)
On Error Resume Next
Call SetSignatureToAccount
EndTimer
End Sub
Sub SetSignatureToAccount()
‘Update by ExtendOffice
Dim xMail As MailItem
Dim xSignatureFile, xSignaturePath As String
Dim xSubject As String
Dim xDoc As Document
Dim xAccount As Account
Dim xIsNew As Boolean
Dim xInspector As Inspector
Const PR_SMTP_ADDRESS As String = "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"
On Error Resume Next
xSignaturePath = CreateObject("WScript.Shell").SpecialFolders(5) + "\Microsoft\Signatures\"
xSubject = GInspector.Caption
Set xDoc = GInspector.WordEditor
xIsNew = False
Set xMail = GInspector.CurrentItem
Select Case xMail.Parent.Parent
Case "name1@example.com" 'Replace the email address in double quotes
If VBA.InStr(xSubject, "RE: ") Then
xSignatureFile = xSignaturePath & "Signature1.htm" 'Replace "Signature1" with your actual signature name that you will set as the signature when you reply to a message.
ElseIf VBA.InStr(xSubject, "FW: ") Then
xSignatureFile = xSignaturePath & "Signature2.htm" 'Replace "Signature2" with your actual signature name that you will set as the signature when you forward a message.
Else
xIsNew = True
Exit Sub
End If
Case "name2@example.com" 'Replace the email address in double quotes
If VBA.InStr(xSubject, "RE: ") Then
xSignatureFile = xSignaturePath & "Signature3.htm" 'Replace "Signature3" with your actual signature name that you will set as the signature when you reply to a message.
ElseIf VBA.InStr(xSubject, "FW: ") Then
xSignatureFile = xSignaturePath & "Signature4.htm" 'Replace "Signature4" with your actual signature name that you will set as the signature when you forward a message.
Else
xIsNew = True
Exit Sub
End If
'Add more Cases for more email accounts
End Select
If xIsNew = True Then
With xDoc.Application.Selection
.WholeStory
.EndKey
.InsertParagraphAfter
.MoveDown Unit:=wdLine, Count:=1
.InsertFile FileName:=xSignatureFile, Link:=False, Attachment:=False
End With
Else
With xDoc.Application.Selection
.MoveRight Unit:=wdCharacter, Count:=1
.HomeKey Emptyparam, Emptyparam
.InsertFile FileName:=xSignatureFile, Link:=False, Attachment:=False
End With
End If
Set xDoc = Nothing
Set GInspector = Nothing
Set xMail = Nothing
End Sub
- 1) 您应将第39行和第48行中的name1@example.com和name2@example.com替换为您的实际电子邮件地址。
- 2) 您应根据注释将第41行、第43行、第50行和第52行中的Signature替换为您的实际签名名称。
- 3) 使用上述VBA代码,我们可以为两个电子邮件帐户添加签名。如果您有更多帐户,请用更多Case替换代码的第57行:
4. 在Microsoft Visual Basic for Applications窗口中,点击“工具 > 引用”,勾选Microsoft Word 16.0 Object Library旁边的框,然后点击确定。

5. 重新启动Outlook,并保存VBA代码。
6. 现在,当您使用已设置签名的电子邮件帐户回复或转发邮件时,相应的签名将自动添加。
注意:如果您发现在使用电子邮件帐户回复或转发邮件时添加了两个签名,请在邮件窗口中点击签名 > 签名。在选择默认签名部分,选择有两个签名的电子邮件帐户,并从回复/转发下拉列表中选择(无)。

相关文章
例如,您从网站下载了一些HTML签名,并希望将它们导入到您的Outlook中。有什么简单的方法吗?本文将指导您逐步将HTML签名导入或插入到Outlook中。
在Outlook的邮件中添加或删除背景颜色很容易。但是,如何在Outlook签名中插入或删除背景颜色呢?以下解决方法将帮助您解决这个问题:
如何在Outlook中创建新邮件时为多个电子邮件帐户添加不同的签名?
如果您希望Outlook在创建新邮件时自动添加签名,则需要通过点击“签名 > 签名”,并为特定电子邮件帐户选择一个签名(如下所示)来配置默认签名。但是,如果您有许多电子邮件帐户,并希望批量为您的多个帐户添加不同的签名该怎么办呢?在本教程中,我将介绍一种VBA方法,帮助您轻松完成此任务。
通常,您可以在Outlook中为不同帐户设置不同的签名,但您是否尝试过为回复和转发应用不同的签名呢?这意味着,当您回复邮件时,插入签名1;当您转发邮件时,应用签名2。如何在Outlook中解决这个任务呢?
最佳办公生产力工具
重磅消息:Kutools for Outlook 推出免费版本!
体验全新 Kutools for Outlook 免费版本,拥有 70 多项令人惊叹的功能,永久免费使用!立即点击下载!
🤖 Kutools AI :利用先进的人工智能技术轻松处理电子邮件,包括回复、总结、优化、扩展、翻译和撰写邮件。
📧 邮件自动化:自动答复(支持 POP 和 IMAP) / 定时发送邮件 / 按规则自动抄送密送 / 自动转发(高级规则) / 自动添加问候语 / 自动将多收件人邮件拆分为单独消息 ...
📨 邮件管理:撤回邮件 / 按主题和其他条件阻止垃圾邮件 / 删除重复邮件 / 高级搜索 / 整合文件夹 ...
📁 附件增强功能:批量保存 / 批量拆离 / 批量压缩 / 自动保存 / 自动拆离 / 自动压缩 ...
🌟 界面魔法:😊更多漂亮酷炫的表情符号 / 当重要邮件到达时提醒您 / 最小化 Outlook 而不是关闭 ...
👍 一键奇效:带附件回复所有人 / 反钓鱼邮件 / 🕘显示发件人的时区 ...
👩🏼🤝👩🏻 联系人和日历:从选定的邮件中批量添加联系人 / 将联系人组拆分为单独的组 / 移除生日提醒 ...
单击即可立即解锁 Kutools for Outlook。不要再等待,现在就下载并提升您的效率!

