Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find Exchange Users in Global Address Lists based on the Email addresses

Status
Not open for further replies.

Bartias

Technical User
Dec 1, 2013
8
PL
Hello everyone

I have a problem with searching for the Exchange User object based on the email address of the person, instead of full name.

The idea behind the script is to go through a list of email addresses in a csv file and output the full names, addresses, job titles along with the email addresses to a different csv file. Here's how I try to access the user object.

Code:
Code:
set appOutlook = CreateObject("Outlook.Application")
	set objNameSpace = appOutlook.GetNameSpace("MAPI")
	set objAddressLists = objNameSpace.AddressLists("Global Address List")
	set objAddressEntry = objAddressLists.AddressEntries("user@mydomain.com").GetExchangeUser()
	
	strFullName = objAddressEntry.Name
	strJobTitle = objAddressEntry.JobTitle
	strBusinessAddress = objAddressEntry.PrimarySmtpAddress
	msgBox strFullName & strJobTitle & strBusinessAddress
The results of the above code are wrong (shows a wrong user), however they are fine if I try the code below, i.e. with a name instead of email address.

Code:
set objAddressEntry = objAddressLists.AddressEntries("John Doe").GetExchangeUser()


At one point I have done it just for my local Contact List, where I was able to use something like that, however I need it for the global address list.

Code:
Set objContact = objContacts.Items.Find("[IMAddress] = ""user@mydomain.com""")

Thanks in advance for help to find specific users on the basis of their email addresses!
 
No, unfortunately - the thing is that it is returning a value "similar" to what is given. For example, if I have a user John Doe with the email address of 'master.exploder@mydomain.com' and I search for 'johnsmith@domain.com' (non-existent email), it will still return me a value of John Doe. More or less. I am not sure how does it search, but it is definately not a case of email assignments, it just returns a value that is closes to the string that I give.
 
Well, I assume that this is because the search engine is made to use Full Name as a default search criteria. But I am sure it's possible to get find users based on email addresses...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top