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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

See if someone's name is in the outlook address book 2

Status
Not open for further replies.

LeanneGodney

Technical User
Mar 7, 2002
175
GB
Hi there,

I've created code that creates about 20 emails with different people in the recipients list (From within a module). At the moment it pulls the persons name and surname and uses that as the address, which then needs to be resolved in Outlook.

What I'd like is to check if someone's name is in the global address book first. Cos if it isn't then I want to print out their details in order to telephone them instead.

Is there any way I can test if a name is in the address book or not?

Thanks for your help,
Leanne
 
I've found out the answer to my own question, so incase someone else needs to know how to do this, here's the answer:


Set objOutlook = CreateObject("Outlook.Application")
Set mynamespace = objOutlook.GetNamespace("MAPI")
Set myaddrlist = mynamespace.AddressLists(1) '1 is Global
Set myaddrentries = myaddrlist.AddressEntries

FullName = "John Smith"

AddressBookDelegate = myaddrentries.Item(FullName).Name

If FullName = AddressBookDelegate Then
AddressExists = True
Else
AddressExists = False
End If
 
Give yourself a star. It's great to see someone working on their own problems and finding the solution. I've quite a few Outlook access routines but usually end up using the browser and trial-and-error methods and/or a bit of research.

----------------------
scking@arinc.com
Life is filled with lessons.
We are responsible for the
results of the quizzes.
-----------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top