Skip to main content

如何在Outlook中按寄件人郵箱域排序和分組?

Author: Kelly Last Modified: 2025-05-13

通常,我們可以輕鬆地在Microsoft Outlook中按寄件人、類別、主題、大小等排列所有郵件。然而,似乎無法按寄件人的郵箱域對郵件進行排序或分組,因為郵件根本沒有「寄件人郵箱域」欄位。在此,我將介紹一種VBA代碼,幫助您為郵件新增一個「域名」欄位,然後輕鬆地在Outlook中按寄件人郵箱域對郵件進行排序和分組。

Office Tab - 啟用 Microsoft Office 中的分頁編輯和瀏覽功能,讓工作變得輕鬆愉快
立即解鎖 Kutools for Outlook 的免費版本,享受超過 70 種功能的無限存取權限
強化您的 Outlook 2024 - 2010 或 Outlook 365,使用這些進階功能。享受 70 多種強大功能,提升您的郵件體驗!

要在Microsoft Outlook 2013和2010中按寄件人郵箱域對郵件進行排序和分組,請按照以下步驟操作:

步驟1:打開您要按寄件人郵箱域對所有郵件進行排序的郵件資料夾。

步驟2:在「檢視」標籤上,點擊「郵件頭」>「關閉」以關閉閱讀窗格。

the screenshot of step about sorting and grouping by sender domain in outlook 1

步驟3:繼續並點擊「檢視」標籤上的「新增欄位」。

the screenshot of step about sorting and grouping by sender domain in outlook 2

步驟3:在「顯示欄位」對話框中,點擊「新建欄位」按鈕。

the screenshot of step about sorting and grouping by sender domain in outlook 3

步驟4:在「新建欄位」對話框中,在「名稱」框中輸入「域名」,並保持「文字 」在「類型」框和「格式」框中被選中,最後點擊「確定」按鈕。

the screenshot of step about sorting and grouping by sender domain in outlook 4

步驟5:現在您回到「顯示欄位」對話框,選擇「域名」在「按此順序顯示這些欄位」框中,將其移動到「」項目下方,然後點擊「確定」按鈕。

the screenshot of step about sorting and grouping by sender domain in outlook 5

步驟6:現在您回到打開的郵件資料夾,同時按下Ctrl + A鍵選擇所有郵件。

步驟7:同時按下Alt + F11鍵打開Microsoft Visual Basic for Applications窗口;然後點擊「插入」 >「模塊」,接著將以下VBA代碼粘貼到模塊中。

VBA:按寄件人郵箱域排序和分組

Sub ListSelectionDomain()
Dim aObj As Object
Dim oProp As Outlook.UserProperty
Dim sDomain
On Error Resume Next
For Each aObj In Application.ActiveExplorer.Selection
Set oMail = aObj
sDomain = Right(oMail.SenderEmailAddress, Len(oMail.SenderEmailAddress) - InStr(1, oMail.SenderEmailAddress, "@"))
Set oProp = oMail.UserProperties.Add("Domain", olText, True)
oProp.Value = sDomain
oMail.Save
Err.Clear
Next
End Sub

步驟8:通過按下工具欄中的F5鍵或「運行」按鈕來運行此VBA代碼。

步驟9:現在每個寄件人的域名已被提取並填入「域名」欄位中。

A. 要按寄件人郵箱域對郵件進行排序,只需點擊所有郵件頂部的「域名」欄位標題;

the screenshot of step about sorting and grouping by sender domain in outlook 6

B. 要按寄件人郵箱域對郵件進行分組,只需右鍵點擊「域名」欄位標題,然後從下拉列表中選擇「按此欄位分組」。見下面的屏幕截圖:

the screenshot of step about sorting and grouping by sender domain in outlook 7

注意

(1) 此VBA代碼在Outlook 2013和2010中運行良好,但在Outlook 2007中不適用。
(2) 您可以輕鬆保存自定義視圖,詳情請參閱如何在Outlook中保存和複製視圖設置到其他資料夾?


相關文章

如何在Outlook的郵件列表中查看寄件人的域名?