HOW TO: Export all email addresses from a domain

by Bharat Suneja

Background: The Active Directory Users & Computers (ADUC) UI lets you list the mail column for each object, which displays the default (SMTP) email address for objects. You can export the list from ADUC to a CSV/txt file. However, any additional email addresses in the proxyAddresses attribute are not exported.

There’s no GUI interface (in ADUC or ESM) to list or export all email addresses. Here’s a script to do that – ListEmailAddresses.vbs.

Download link updated to non-HTTPS.

What does it exactly do?

  1. Queries Active Directory for Contacts & Groups
  2. Lists their email addresses
  3. Queries Users
  4. Lists enabled users’ email addresses
  5. Lists disabled users’ email addresses separately (was required for a certain project I did a long time back)
  6. Outputs to command line and also to a text file – c:\proxyaddresses.txt
    X.400 addresses are ignored

Related Posts

{ 38 comments… read them below or add one }

Anonymous January 29, 2010 at 5:09 am

U da man!!!


small business February 17, 2010 at 11:22 am

Thanks for the info! This is what I needed!


Small Business February 18, 2010 at 3:52 pm

I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.
Thank you,


Anonymous April 4, 2010 at 7:19 pm

i get an error on line 54 char 13 anyone know why


Anonymous April 5, 2010 at 6:27 pm

Last anonymous – see the comment from December 11, 2009 from

You likely have a user or group name with a "/" in it. The line from the above comment must be added at line 54 and again at line 101.

It is a right useful script. I do need to hack at it to get it to enumerate public folders and other Exchange Recipient objects.


Anonymous April 6, 2010 at 3:06 pm

Great script. Amazing that Exchange Management Console doesn't offer this (and other equivalent) functionality.


Ricardo Santos April 23, 2010 at 4:25 am

Thank you so much, it was a great help!!!

Here's the condition I used to get only the PRIMARY e-mails:

If Left (ProxyAddress,5) = "SMTP:" Then
strResult = strResult & VbCrlf & proxyAddress
AddressCount = AddressCount + 1
End If

Thank you!!


Jesse January 12, 2011 at 1:33 pm

Ricardo, Where did you insert the code you used to filter for only primary? I tried putting it just before the text file gets created but that didn’t work, although I received no error.


Anonymous July 16, 2010 at 10:16 pm

Hi there fantasic blog and script, I have no idea regarding scripting, I have looked into the code to see if I could modify it but it really isnt clear for me! I need to add atleast the ‘Title’ attribute from the organisation tab in AD and it would be great if I could also add the ‘Department’ and ‘Company’ attributes to the output, per user. If it is fairly straigh forward to do could somebody post the amended code or point me in the direction of which sections need modifying to do this. Thanks very much and have a great weekend. Keith


Jose August 18, 2010 at 10:18 pm

The mailbox which i disabled is not showing in the Disconnected mailboxes. I have checked the settings under: Mailbox Database Properties -> Limits -> Keep deleted mailboxes for(Days)=30. Can’t figure out how the mailbox disappeared. Now, I want the mailbox as needs to refer to very important emails from it. Can Anyone help…. please?????? Jose Fernz…


Lars Petersson August 25, 2010 at 5:31 am

Great script. Unfortunately it only returns a bit under 500 results for me, and we have much more than that here…

There are no errors though…


Steve Cooper September 14, 2010 at 8:05 am

great little script. saved hours of work.
Don’t suppose you know of a utility to globally change users passwords in AD by taking info from a pre-selected list


GeekChick September 29, 2010 at 2:01 pm

THANK YOU!!!! I needed a list of email addresses to import. This worked like a champ.


dspanic December 29, 2010 at 2:02 pm

Is it possible in list to add size of email?


VaartM January 7, 2011 at 2:20 am

greate script


okika January 13, 2011 at 10:25 am
Exchange Recovery January 24, 2011 at 12:56 am


Thanks for this interesting and helpful script!


Suneth February 18, 2011 at 10:13 pm

What are the lines i have to edit to get email address.
if my domain is ‘’

i change line 54
“LDAP://”& strUserDN & “”

i change line 100
set objUser= GetObject(“LDAP://”& strUserDN & “”)

but still it gives error message that
‘The specified domain either does not exit or …”

please help


Matt February 28, 2011 at 4:12 am

Suneth, you shouldnt need to edit the script. just download and extract. Run on the server and then close the script output window. On the root of the c drive you should see a text file called proxyaddresses.txt open this and you should see the list of the users with email addresses listed under them.

When SMTP is in CAPS this shows that it is the primary SMTP mail address.


Jon April 21, 2011 at 7:17 am

Awesome script… Taking it one step further… Could this be used in conjunction with something else to take any disabled users with an email address and CLEAR it out…… We are running into an issue with disabled users retaining their email address even though their mailbox was deleted. That is messing up our Mimecast.
Thanks in advance…


chuck May 4, 2011 at 2:45 pm

You rock dude!


Eric Ramljak June 28, 2011 at 6:57 am

Awesome script, saved much time.
Thanks for your work


Pal Amundsen September 22, 2011 at 5:48 am

Thank you! Just what I needed :-)


MOHAMMED October 17, 2011 at 1:38 am

Hi Every one im not like u guys… i assigned work to pull up 960 users email address from AD and update them in Excel file.. can any one help me how to get there email address in a easy way inspite of pulling every ones account and copy the email address…
And users are from diff locations and account/ domains..from US


shawn October 24, 2011 at 2:18 am

The size limit for this request was exceeded

The script returns the above error. This is a very large domain in excess of 40,000 users. Any way to modify the script to return more results?


Nicholas Callahan November 13, 2011 at 7:06 pm

When I run your script I get a Windows Script Host error. It says:

Line: 158
Char: 6
Error: The size limit for this request was exceeded
Code: 80072023
Source: Provider

Do you have how to get your script to download the whole directory?


Michael K December 8, 2011 at 12:17 pm

I have the same question about Line 158, char: 6. Any fix for this?


Jason M January 3, 2012 at 2:08 pm

Pretty new to this, so I’m sure I’m doing something wrong. I downloaded this script, copied it to my domain controller and double clicked it. Nothing happened…no errors, no proxyaddresses.txt on the C:\ How am I supposed to run this script exactly?


Bharat Suneja January 3, 2012 at 5:58 pm

Open a command window (Start > Run > Cmd), use CSCRIPT to run a script (or you can also set default script execution engine to CSCRIPT).


Shariful March 14, 2012 at 6:21 am

can anyone suggest any solution/software, by which i’ll be able to get email addresses from certain domains? not such email address generators which only generates emails from hotmail or yahoo….such as, if i’d like to generate email address, which are associated with ….any idea will be welcome.


Sandeep April 27, 2012 at 6:49 pm

I am trying to download the script but server is timing out…can you please email or send us another link to download


Matt May 18, 2012 at 5:13 pm

Sandeep: the link redirects you to the https (secure) version of Exchangepedia. Just remove the ‘s’ from ‘https’ and it’ll download fine.


Hayden kirk May 17, 2012 at 5:18 pm

I have put a link up as I needed the file as well. Lucky I still had it on another server.



Javier June 13, 2012 at 11:10 am

Hi im very interested to hiring somebody else, to help me to set this script as i want. please send me an email to [email protected]


aaron June 21, 2012 at 6:36 pm

What a fantastic tool!
Makes migration much easier.


Serg June 22, 2012 at 6:40 am – exports all email contacts and all email addresses ever met at your mailbox (gmail, yahoo , etc ). free


Data Recovery April 8, 2013 at 1:48 am


Thanks for this interesting and helpful script!


Dan July 15, 2013 at 2:41 pm

nice script!! Did exactly what i needed and it still works. Just be sure to put the file in the root of the c:\ so that it can create the necessary .txt file in that same location


Leave a Comment

{ 3 trackbacks }

Previous post:

Next post: