A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Searching GAL for telephone number



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 17th 07, 07:06 PM posted to microsoft.public.outlook.program_vba
J Streger
external usenet poster
 
Posts: 4
Default 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

Ads
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
searching for telephone numbers Roy Outlook - General Queries 2 June 29th 07 09:25 PM
Search for contact by telephone number? Massiverugsale Outlook - Using Contacts 4 October 9th 06 01:25 PM
Find a contact by telephone number Angus Comber Outlook and VBA 3 April 7th 06 05:05 PM
Annoying telephone number formatiing Alphonse Outlook - Installation 4 April 1st 06 07:24 AM
show primary telephone number first? Brian Tillman Outlook - Using Contacts 0 January 11th 06 03:36 PM


All times are GMT +1. The time now is 03:01 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.