Hi,
sorry for my bad english.
In a VBA function for Outlook, I want to look up the address passed to the function in the address book.
If I scan the addresslists, select the addresslist of interest and scan all the contacts, I can find the contact I am looking for (if exist).
This method is fine if I scan my personal address book with few contacts, but in the global address book I have more than 20,000 contacts, a full scan is not possible.
I thought about using the restrict method, but it can only be used on a folder, and I can only find the folder of the personal address book, not for the global address book (first problem).
I applied the restrict method on the personal address book.
I get the contacts I am looking for correctly, and so far so good.
When the search returns a distribution list, I can't see individual members.
I get the number of members that make up the list, but when I go to see its contents I get for each item a string of incomprehensible characters and not an contact object (second problem).
Function GetAddressList(AddressesToCheck As String) As String 'addressbook As String,
' Returns the requested e-mail, taking it from an address book.
Dim AddressesToCheckList As Variant
Dim ExludedAddressesList() As Variant
Dim IncludedAddressesList() As Variant
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim AddressList As Outlook.AddressList
Dim ItemFiltered As Items
Set AddressList = objNS.Application.Session.AddressLists("Contatti")
' [ cut code for explode address list into array]
For i = 0 To UBound(IncludedAddressesList)
Set ItemFiltered = AddressList.GetContactsFolder.Items.Restrict("[FullName] = " & Chr(34) & IncludedAddressesList(i) & Chr(34))
If ItemFiltered.Count <> 0 Then
For j = 1 To ItemFiltered.Count
If ItemFiltered(j).Class = olDistributionList Then
If ItemFiltered(j).MemberCount > 0 Then
For k = 0 To ItemFiltered(j).MemberCount - 1
Debug.Print "Contact into distribution list: "; ItemFiltered(j).Members(k)
Next k
End If
ElseIf ItemFiltered(j).Class = olContact Then
Debug.Print "Contact: "; ItemFiltered(j)
Else
Debug.Print "Unknow item "; ItemFiltered(j); " - "; ItemFiltered(j).Class
End If
Next j
End If
Next i
End Function 'GetAddressList
Thanks for your support.