如何在 Outlook 中根據特定域導出電子郵件地址?
如果您想從 Outlook 中的所有聯繫人中導出具有特定域的電子郵件地址,請閱讀本教程,該教程將幫助您應用 VBA 代碼將特定域中的所有電子郵件地址提取到文本文件中,如下圖所示.
使用 VBA 代碼在 Outlook 中基於特定域導出電子郵件地址
要從所有聯繫人中提取具有特定域的所有電子郵件地址,請執行以下步驟:
1. 創建一個新的文本文件並為其命名,請參見屏幕截圖:
2。 按住 ALT + F11 鍵打開 Microsoft Visual Basic for Applications 窗口。
3。 然後,點擊 插入 > 模塊,然後將以下代碼粘貼到“模塊窗口”中。
VBA 代碼:根據特定域導出電子郵件地址
Dim GDomain As String
Dim GFileSystem As Object
Dim GFilePath As String
Dim GFileObj As Object
Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, _
ByVal ipOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Sub ExportListOfEmailAddressesInSpecificDomain()
'Updateby ExtendOffice
Dim xStore As Store
Dim xFolder As Folder
On Error Resume Next
GDomain = InputBox("Enter domain(@***.com):", "Kutools for Outlook")
If Len(GDomain) <> 0 Then
GFilePath = "C:\Users\skyyang\Desktop\Email Addresses with specific domain.txt" 'Specify the file path
Set GFileSystem = CreateObject("Scripting.FileSystemObject")
Set GFileObj = GFileSystem.CreateTextFile(GFilePath, True)
For Each xStore In Application.Session.Stores
For Each xFolder In xStore.GetRootFolder.Folders
If xFolder.DefaultItemType = olContactItem Then
Call ProcessFolders(xFolder)
End If
Next
Next
GFileObj.Close
ShellExecute 0&, vbNullString, GFilePath, vbNullString, vbNullString, 1
End If
End Sub
Sub ProcessFolders(ByVal Fld As Outlook.Folder)
Dim xContactItems As Items
Dim I As Long
Dim xContact As ContactItem
Dim xSubFolder As Folder
On Error Resume Next
Set xContactItems = Fld.Items
For I = xContactItems.Count To 1 Step -1
If xContactItems(I).Class = olContact Then
Set xContact = xContactItems(I)
If InStr(xContact.Email1Address, GDomain) > 0 Then
GFileObj.WriteLine (xContact.Email1Address & vbCrLf)
ElseIf InStr(xContact.Email2Address, GDomain) > 0 Then
GFileObj.WriteLine (xContact.Email2Address & vbCrLf)
ElseIf InStr(xContact.Email3Address, GDomain) > 0 Then
GFileObj.WriteLine (xContact.Email3Address & vbCrLf)
End If
End If
Next
If Fld.Folders.Count > 0 Then
For Each xSubFolder In Fld.Folders
If xSubFolder.DefaultItemType = olContactItem Then
Call ProcessFolders(xSubFolder)
End If
Next
End If
End Sub
4。 然後,按 F5 運行此代碼的關鍵。 彈出一個提示框,請輸入您要導出電子郵件地址的電子郵件域,見截圖:
5。 然後,點擊 OK 按鈕,然後將特定域中的所有電子郵件地址一次性提取到文本文件中,見截圖:
最佳辦公生產力工具
Kutools for Outlook - 超過 100 種強大的功能可增強您的 Outlook
🤖 人工智慧郵件助手: 具備人工智慧魔力的即時專業電子郵件——一鍵天才回覆、完美語調、多語言掌握。輕鬆改變電子郵件! ……
📧 電子郵件自動化: 外出(適用於 POP 和 IMAP) / 安排發送電子郵件 / 發送電子郵件時按規則自動抄送/密件副本 / 自動轉送(進階規則) / 自動添加問候語 / 自動將多收件者電子郵件拆分為單獨的訊息 ...
📨 電子郵件管理: 輕鬆回憶電子郵件 / 按主題和其他人阻止詐騙電子郵件 / 刪除重複的電子郵件 / 進階搜索 / 合併資料夾 ...
📁 附件專業版: 批量保存 / 批量分離 / 批量壓縮 / 自動保存 / 自動分離 / 自動壓縮 ...
🌟 介面魔法: 😊更多又漂亮又酷的表情符號 / 使用選項卡式視圖提高 Outlook 工作效率 / 最小化 Outlook 而不是關閉 ...
👍 一鍵奇蹟: 使用傳入附件回覆全部 / 反網路釣魚電子郵件 / 🕘顯示寄件者的時區 ...
👩🏼🤝👩🏻 通訊錄和行事曆: 從選定的電子郵件中大量新增聯絡人 / 將聯絡人群組拆分為各組 / 刪除生日提醒 ...
超過 100特點 等待您的探索! 按此處了解更多。