如何在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行:
If VBA.InStr(xSubject, "RE: ") = 1 Then
xSignatureFile = xSignaturePath & "Signature1.htm"
ElseIf VBA.InStr(xSubject, "FW: ") = 1 Then
xSignatureFile = xSignaturePath & "Signature2.htm"
Else
xIsNew = True
Exit Sub
End If
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中的不同帳號設置不同的簽名,但您是否嘗試過為回覆和轉寄應用不同的簽名呢?這意味著,當您回覆郵件時,插入signature1;當您轉寄郵件時,應用signature2。您如何在Outlook中解決這個問題呢?
最佳辦公室生產力工具
最新消息:Kutools for Outlook推出免費版本!
體驗全新的Kutools for Outlook免費版本,擁有70多項令人驚嘆的功能,永久使用!立即點擊下載!
🤖 Kutools AI :使用先進的AI技術輕鬆處理郵件,包括答覆、摘要、優化、擴展、翻譯和撰寫郵件。
📧 郵件自動化:自動回覆(適用於POP和IMAP) / 計劃發送郵件 / 發送郵件時按規則自動抄送密送 / 自動轉發(高級規則) / 自動新增問候語 / 自動將多收件人郵件拆分為個別郵件...
📨 郵件管理:撤回郵件 / 按主題和其他方式阻止詐騙郵件 / 刪除重複郵件 / 高級搜索 / 整合文件夾...
📁 附件專業版:批量保存 / 批量拆離 / 批量壓縮 / 自動保存 / 自動拆離 / 自動壓縮...
🌟 介面魔法:😊更多漂亮和酷炫的表情符号 / 當重要郵件到來時提醒您 / 最小化Outlook而不是關閉...
👍 一鍵奇蹟:帶附件全部答復 / 防止網絡釣魚郵件 / 🕘顯示發件人的時區...
👩🏼🤝👩🏻 聯絡人和日曆:從選中郵件批量新增聯絡人 / 將聯絡人組拆分為個別組 / 移除生日提醒...
立即單擊解鎖Kutools for Outlook。不要等待,立即下載並提升您的效率!

