Skip to main content

如何在Outlook中將所有收件人姓名插入郵件正文中?

Author: Xiaoyang Last Modified: 2025-08-06

有時候,在Outlook中撰寫郵件時,您可能需要將所有收件人的姓名插入到郵件正文中。當然,您可以逐一複製並將姓名粘貼到正文中,但如果需要粘貼幾十個收件人姓名,這樣做會非常繁瑣。本文將介紹一種簡單的方法來完成此操作。

使用VBA代碼在Outlook中將所有收件人姓名插入郵件正文


使用VBA代碼在Outlook中將所有收件人姓名插入郵件正文

以下VBA代碼可以幫助您將“收件人”欄位中的所有姓名插入到郵件正文中,請按照以下步驟操作:

1. 啟動Outlook,然後按住ALT + F11鍵打開Microsoft Visual Basic for Applications窗口。

2. 點擊 插入 > 模組,並在模組窗口中粘貼以下代碼。

VBA代碼:將收件人姓名插入郵件正文:

Sub InsertRecipientNamesToBody()
Dim xMailItem As Outlook.MailItem
Dim xRecipient As Outlook.Recipient
Dim xRecipAddress, xRecipNames, xRecipName, xFilterAddr As String
Dim xItems As Outlook.Items
Dim i As Integer
Dim xFoundContact As Outlook.ContactItem
Dim xDoc As Word.Document
On Error Resume Next
Set xMailItem = Outlook.ActiveInspector.CurrentItem
xMailItem.Recipients.ResolveAll
For Each xRecipient In xMailItem.Recipients
    xRecipAddress = xRecipient.Address
    Set xItems = Application.Session.GetDefaultFolder(olFolderContacts).Items
    For i = 1 To 3
        xFilterAddr = "[Email" & i & "Address] = " & xRecipAddress
        Set xFoundContact = xItems.Find(xFilterAddr)
        If Not (xFoundContact Is Nothing) Then
           xRecipNames = xRecipNames & xFoundContact.FullName & Chr(10)
           Exit For
        End If
    Next
    If (xFoundContact Is Nothing) Then
       xRecipName = Split(xRecipAddress, "@")(0)
       xRecipNames = xRecipNames & xRecipName & Chr(10)
    End If
Next
Set xDoc = xMailItem.GetInspector.WordEditor
xDoc.Content.InsertAfter xRecipNames
Set xMailItem = Nothing
Set xRecipient = Nothing
Set xItems = Nothing
Set xFoundContact = Nothing
End Sub

3. 然後仍然在Microsoft Visual Basic for Applications窗口中,點擊工具 > 參考,進入References-Project1對話框,並從可用參考列表框中勾選Microsoft Word Object Library選項,見截圖:

the screenshot of step about inserting all recipient names to email body in outlook 1

4. 然後點擊確定關閉對話框,現在,您應該將此代碼添加到快速訪問工具欄中。

5. 點擊新建郵件創建新郵件,在郵件窗口中,點擊用戶自定義快速訪問工具欄圖標,並選擇 更多命令,見截圖:

the screenshot of step about inserting all recipient names to email body in outlook 2

6. 在 Outlook選項對話框中:

(1.) 從選擇命令來自下拉列表中選擇

(2.) 然後選擇剛才插入的VBA代碼名稱;

(3.) 點擊新增按鈕將代碼添加到自定義快速訪問工具欄列表框中。

the screenshot of step about inserting all recipient names to email body in outlook 3

7. 然後一個宏圖標將顯示在快速訪問工具欄中,如下截圖所示:

the screenshot of step about inserting all recipient names to email body in outlook 4

8. 現在,當您點擊該宏圖標時,“收件人”欄位中的姓名將被插入到郵件正文中,如下截圖所示:

the screenshot of step about inserting all recipient names to email body in outlook 5

最佳 Office 生產力工具

最新消息:Kutools for Outlook 推出免費版本!

體驗全新 Kutools for Outlook,擁有100+ 強大功能!立即下載!

🤖 Kutools AI 運用先進 AI 技術,輕鬆處理郵件,包括答覆、摘要、優化、擴寫、翻譯與撰寫郵件。

📧 郵件自動化自動回覆(支援 POP 和 IMAP) / 計劃發送郵件 / 發送郵件時根據規則自動抄送密送 / 自動轉發(高級規則) / 自動新增問候語 / 自動將多收件人郵件分割為個別郵件 ...

📨 郵件管理撤回郵件 /依主題等條件阻擋詐騙郵件 / 刪除重複郵件 / 高級搜索 / 整合文件夾 ...

📁 附件專業版批次保存 / 批次拆離 / 批次壓縮 / 自動保存 / 自動拆離 / 自動壓縮 ...

🌟 介面魔法😊更多精美酷炫表情符號 /重要郵件來臨提醒 / 最小化 Outlook 而非關閉 ...

👍 一鍵神技帶附件全部答復 /反釣魚郵件 / 🕘顯示發件人時區 ...

👩🏼‍🤝‍👩🏻 聯絡人與日曆批次從選中郵件新增聯絡人 / 將聯絡人組分割為多個組 / 移除生日提醒 ...

以您偏好的語言使用 Kutools —— 支援英語、西班牙語、德語、法語、中文及40 多種其他語言!

只需一鍵即可立即啟用 Kutools for Outlook。立即下載,提升您的效率!

kutools for outlook features1 kutools for outlook features2