I tried this code to find contacts in GAL by jobtitle.
Sub FindEmailsByJobTitle()
Dim olApp As Outlook.Application
Dim oGAL As Outlook.AddressList
Dim oContacts As Outlook.AddressEntries
Dim oContact As Outlook.ContactItem
Dim oResults As Outlook.Items
Dim sFilter As String
Dim sJobTitle As String
Set olApp = Outlook.Application
Set oGAL = olApp.Session.AddressLists("Global Address List")
sJobTitle = "MANAGER"
sFilter = "@SQL=" & Chr(34) & "urn:schemas:contacts:JobTitle" & Chr(34) & " LIKE '%" & sJobTitle & "%'"
Set oResults = oGAL.AddressEntries.GetFirst().AddressList.Find(sFilter) 'this is error
If Not oResults Is Nothing Then
For Each oContact In oResults
Debug.Print oContact.Address
Next oContact
Else
MsgBox "No contacts found."
End If
Set oResults = Nothing
Set oContacts = Nothing
Set oGAL = Nothing
Set olApp = Nothing
End Sub
It throws an error
Object doesn't support this property or method
AddressEntriesobject does not supportFindmethod. Generally, search support by the address containers is very basic compared to searching in message store folders (Items.Find/FindNext/Restrict).The best you can do in OOM is
Namespace.CreateRecipient/Recipient.Resolveand hope that the given value can be uniquely resolved.If using Redemption (I am its author) is an option, you can filter on a few properties explicitly exposed by GAL for searching (Alias, City, Company, Department, First Name, Last Name, Office, Title). This is what you see in the address book window in Outlook if you click "Advanced Find". Redemption exposes it through the RDOAddressListSearch object: