Get email addressees of all users from all mails in Outlook Folder
Original Article:
http://msmvps.com/blogs/omar/archive/2006/08/09/get-email-address-of-all-users-from-all-mails-in-outlook-folder.aspx
Sometimes you want to send some important notice to everyone who has ever mailed you. Let's say you have a folder named "Friends" in Outlook where you store all the emails from your friends. Now you want to get all of their email addresses (from the folder, not from the email bodies). Pretty difficult work if you have thousands of such mails. Here's an easy way.
Hit F5 and it will run for a while. Then press Ctrl+G. You will see the email addresses in the "Immediate Window".
Copy the whole string and you have all the email addresses from all the emails in the selected Outlook folder. There will be no duplicate address in the list.
Sub GetALLEmailAddresses()
Dim objFolder As MAPIFolder
Dim strEmail As String
Dim strEmails As String
''' Requires reference to Microsoft Scripting Runtime
Dim dic As New Dictionary
Dim objItem As Object
''Set objFolder = Application.ActiveExplorer.Selection
Set objFolder = Application.GetNamespace("Mapi").PickFolder
For Each objItem In objFolder.Items
If objItem.Class = olMail Then
strEmail = objItem.SenderEmailAddress
If Not dic.Exists(strEmail) Then
strEmails = strEmails + strEmail + vbCrLf
dic.Add strEmail, ""
End If
End If
Next
Debug.Print strEmails
End Sub