3
votes

Is there anyway to search Outlook address box for a contact using their email address without any sort of For Loops? There are so many contacts in our Global Contact List and it takes forever to go through the list. Is there no search or find function that can be applied to the contact list.

I am looking to get information like the phone # and office for the user if they are found in the contact list.

All the solutions that I have found involve looping through the contact list. http://www.ozgrid.com/forum/showthread.php?t=76588

https://msdn.microsoft.com/en-us/library/office/ff869721.aspx

2

2 Answers

2
votes

Use Namespace.CreateRecipient / Recipient.Resolve to resolve the name (or address) in the address book. Even if you pass an SMTP address, it will be resolved to a GAL user (if there is a match).

1
votes

This is the solution that I am using to get the phone # of a contact using the email address from the global address book - using Dmitry Streblechenko approach.

Sub GetPhone(EmailAddress As String) 'Gets the phone # for contact
Dim OutApp As Outlook.Application
Dim OutMail As Object
Dim OutRecipients As Outlook.Recipient
Dim PhoNe As String


On Error Resume Next
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

Set OutRecipients = OutMail.Recipients.Add(EmailAddress)
OutRecipients.Resolve

PhoNe = OutRecipients.AddressEntry.GetExchangeUser.BusinessTelephoneNumber
Set OutRecipients = Nothing
Set OutMail = Nothing
Set OutApp = Nothing
On Error GoTo 0
End Sub