Geeks With Blogs

News


Rodney Vinyard - .NET & SQL Developer When all is said and done, more will be said than done

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.

  • Select the folder in Outlook and press ALT+F11. It will open Visual Basic Editor.
  • Double click on ThisOutlookSession from the Project tree.
  • Set a reference to Microsoft Scripting Dictionary

  • Paste the following function:

 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

 

Posted on Saturday, November 8, 2008 2:06 AM miscellaneous | Back to top


Comments on this post: Get email addressees of all users from all mails in Outlook Folder

# $2000 Share the SharePoint Contest (MOSS or WSS)
Requesting Gravatar...
Please blog "Share the SharePoint" contest started September 1, running through October 16, 2009, with the first place award of $2000. Microsoft is participating as one of the judges along with Georgia Tech and other commercial organizations, for SharePoint sites that meet certain Rules and Guidelines for submission which can be found along with FAQ's, etc. at www.sharepointportals.com . In addition to the awards, entrants will be considered for a case study or video. Only submissions from Alabama, Georgia, Florida, Tennessee, North Carolina, and South Carolina are eligible. Second and third place awards are valued at approximately $500.
Left by Ken Guthrie on Sep 02, 2009 7:30 PM

# re: Get email addressees of all users from all mails in Outlook Folder
Requesting Gravatar...
This is getting into an error

dic As New Dictionary
Left by Sk on Jul 25, 2011 4:38 AM

# re: Get email addressees of all users from all mails in Outlook Folder
Requesting Gravatar...

This is getting into an error

dic As New Dictionary
Left by Johnny on Jul 31, 2011 4:59 PM

# re: Get email addressees of all users from all mails in Outlook Folder
Requesting Gravatar...
It is missing a referense that is why you are getting the errors Sk and Johnny.
Go to tools, references, and then select the Microsoft Script*** options. then try again.
To see results, keep the immediate window open (View/Immediate Window)
Left by gator geek on Sep 22, 2011 6:52 PM

# re: Get email addressees of all users from all mails in Outlook Folder
Requesting Gravatar...
Hi,

Same problem happening with me. When I tried to click References ... in Tools, it could not be clicked as it shown little hide.

Now what to do, kindly guide.

Prasanna Acharya
Left by PRASANNA ACHARYA on Oct 25, 2011 6:20 PM

# re: Get email addressees of all users from all mails in Outlook Folder
Requesting Gravatar...
thanks man..it works perfect on my outlook 2010
Left by joe malaysia on Nov 13, 2011 5:36 AM

# re: Get email addressees of all users from all mails in Outlook Folder
Requesting Gravatar...
Unfortunately all it is doing for my 2010 acct is pulling the sent from addresses, not the sent to... I currently have three accounts set up in my Outlook 2010.
Left by Belynda on Nov 22, 2011 7:58 PM

# re: Get email addressees of all users from all mails in Outlook Folder
Requesting Gravatar...
How to run this code for all folders whithout selecting one by one?
Left by Mina on Dec 27, 2011 4:10 PM

# re: Get email addressees of all users from all mails in Outlook Folder
Requesting Gravatar...
Hello Guys,

I am using outlook 2010 professional 64bit, can anybody help me out to get the email ids from my outlook, I have more than 1lakh email in my inbox. So, it would be really helpful for me if you provide me the solution.

Thank you,

Regards,
Vijay
Left by Vijay Kumar on Dec 28, 2011 1:57 PM

# re: Get email addressees of all users from all mails in Outlook Folder
Requesting Gravatar...
There's a typo in the beginning of the article:

Set a reference to Microsoft Scripting Dictionary

should be

Set a reference to Microsoft Scripting Runtime

It's very minor but Microsoft Scripting Dictionary doesn't exist in the reference list.
Left by Alex Stanhope on Mar 13, 2012 8:06 AM

# re: Get email addressees of all users from all mails in Outlook Folder
Requesting Gravatar...
Isnt this function the same as using Import export in outlook where you can extract all the email ids from each folder ?
Left by Lochana Shetty on Nov 03, 2012 3:18 AM

# re: Get email addressees of all users from all mails in Outlook Folder
Requesting Gravatar...
I tried the same for multiple folders I have created.But every time, it gives me only 198 email ids whereas the folder contains mails that are beyond 2000. Please help.
Left by Harish on Jan 02, 2013 7:29 AM

# re: Get email addressees of all users from all mails in Outlook Folder
Requesting Gravatar...
Works perfectly. Thanks alot.
Left by GAYAN on Apr 07, 2013 10:54 PM

# re: Get email addressees of all users from all mails in Outlook Folder
Requesting Gravatar...
I want to thank you for the efforts you made while writing this article. I hope the best work you even in the future too.
Left by prime institute of technology Lo on Apr 14, 2013 5:28 AM

Your comment:
 (will show your gravatar)


Copyright © Rodney Vinyard | Powered by: GeeksWithBlogs.net