Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Searching GAL for telephone number (http://www.outlookbanter.com/outlook-vba/52715-searching-gal-telephone-number.html)

J Streger July 17th 07 07:06 PM

Searching GAL for telephone number
 
I know the address book has a search function. If there any way to
programatically serach through the address book, rather than looping through
every single entry?

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003



"Eric Legault [MVP - Outlook]" wrote:

AFAIK, there is no way to use the Exchange SDK to determine which mailboxes
are currently logged into (even though you can see last login times with
Exchange System Manager). Perhaps you can use WMI to read this data, I'm not
sure - don't know much about WMI.

From the client side, you could write a VBA macro or COM Add-In to log
application startup/shutdowns, but you would need to do this on every PC
running Outlook.

Other alternatives could be to integrate with Windows Messenger to read
presence status:

Windows Messenger:
http://msdn.microsoft.com/library/en...asp?frame=true

Or build your own messenger app to do this:

Enhancing Rich Client Communications with the Microsoft Real-Time
Communications API (Windows XP Technical Articles):
http://msdn.microsoft.com/library/en...asp?frame=true

Anyway, if detecting online presence is not a priority, you can still search
the GAL for a specific business telephone number, but you need to use CDO.
Here's an example that loops through the entire GAL looking for a user's full
name. You can easily change it to look for the phone number:

Sub GetGALAddressDetails(UserFullName As String)
On Error Resume Next

Dim objSession As New MAPI.Session
Dim objAdds As MAPI.AddressLists
Dim objAddress As MAPI.AddressEntry
Dim objGAL As MAPI.AddressList
Dim objFields As MAPI.Fields, objField As MAPI.Field

objSession.Logon , , , False

If objSession Is Nothing Then Exit Sub

Set objAdds = objSession.AddressLists
Set objGAL = objAdds.Item("Global Address List")
For Each objAddress In objGAL.AddressEntries
If objAddress.DisplayType = CdoUser Or objAddress.DisplayType =
CdoRemoteUser Then
If InStr(objAddress.Name, UserFullName) 0 Then
Set objField = objAddress.Fields(CdoPR_BUSINESS_ADDRESS_CITY)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField =
objAddress.Fields(CdoPR_BUSINESS_ADDRESS_COUNTRY)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField =
objAddress.Fields(CdoPR_BUSINESS_ADDRESS_POSTAL_CO DE)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField =
objAddress.Fields(CdoPR_BUSINESS_ADDRESS_STATE_OR_ PROVINCE)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField =
objAddress.Fields(CdoPR_BUSINESS_ADDRESS_STREET)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField = objAddress.Fields(CdoPR_TITLE)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField = objAddress.Fields(CdoPR_COMPANY_NAME)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField = objAddress.Fields(CdoPR_DEPARTMENT_NAME)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField = objAddress.Fields(CdoPR_OFFICE_LOCATION)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField = objAddress.Fields(CdoPR_ASSISTANT)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
Set objField =
objAddress.Fields(CdoPR_BUSINESS_TELEPHONE_NUMBER)
If Not objField Is Nothing Then Debug.Print objField.Value:
Set objField = Nothing
End If
End If
Next

objSession.Logoff

Set objSession = Nothing
Set objAdds = Nothing
Set objAddress = Nothing
Set objGAL = Nothing
Set objFields = Nothing
Set objField = Nothing
End Sub


--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Matthias" wrote:


hi,

i would like to search the outlook address book (not contacts) of a running
outlook instance (exchange-session etc established) for an user with a given
telephone number but am a bit overwhelmed by the many api's around.
nonetheless, by reading documentation i could not find a way of doing this.
can anyone give me a hint on what to use?

many thanks,
Matthias



All times are GMT +1. The time now is 11:33 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com