Vasily A
Vasily A

Reputation: 8646

Get Contact Group by its name (instead of checking each item in olFolderContacts)

I need to address a Contact Group of my Outlook. Right now I have to go through all the items in my Contacts:

Set ContactsFolder = Application.Session.GetDefaultFolder(olFolderContacts)
Set contactItems = ContactsFolder.Items
iCount = contactItems.Count
For i = 1 To iCount
    Set thisItem = contactItems.Item(i)
    If TypeName(thisItem) = "DistListItem" And thisItem = "promo_spam" Then
     Set myDLGroup = thisItem
     Exit For
    End If
Next i

is there any better way to get it? I was thinking about something like ContactsFolder.Items.Find but couldn't find the right way to use it...

Upvotes: 1

Views: 96

Answers (1)

niton
niton

Reputation: 9199

The code you are using is normally for listing items in a group.

If you already know the name then:

Set myDLGroup = contactItems("promo_spam") 

Upvotes: 1

Related Questions