I have the following code to import all contacts from Outlook.
Dim olApp As Outlook.Application
Dim olNamespace As Outlook.Namespace
Dim olFolder As Outlook.MAPIFolder
Dim olConItems As Outlook.Items
Dim olItem As Object
Set olApp = New Outlook.Application
Set olNamespace = olApp.GetNamespace("MAPI")
Set olFolder = olNamespace.GetDefaultFolder(olFolderContacts)
Set olConItems = olFolder.Items
'HERE IS THE PROBLEM I do not know how to do so that there are only contacts from my desired group in the olConItems collection
For Each olItem In olConItems
If TypeName(olItem) = "ContactItem" Then
'Do something - no problem I just do not want to post unnecessary code
End If
Next olItem
I need to import only those which belong to a certain contact group. How can I get the contacts group property? Is it somehow exposed?
The subroutine retrieves names from the "MyGroupName" contact group in Outlook and lists them in the active worksheet.
Loop from 1 to DistListItem.MemberCount and call DistListItem.GetMember - it will return Recipient object. If Recipient object properties are not enough, read Recipient.AddressEntry to get AddressEntry object.