Check for the distribution list existence

P

paresh

Hi,

I have written attached code for creating distribution list and
adding/enumerating it's members. I want to put a check before creating
distribution list or adding members into existed distribution list.
1. If DL is exists then it should not create it again and it should
add member to existed DL.
2. If DL is not exists then it should create it and add member.

Thanks.

Dim DL As Outlook.DistListItem
Dim rcp As Outlook.Recipient
Set DL = Application.CreateItem(olDistributionListItem)
DL.DLName = "MyList"

Set rcp = Application.Session.CreateRecipient(userName)
rcp.Resolve
If rcp.Resolved = True Then
DL.AddMember rcp
End If

DL.Save
 
K

Ken Slovak - [MVP - Outlook]

You need to go to every folder where a DL might exist, starting with the
default Contacts folder. You can then filter the Items collection for each
of those folders for distribution list items and see if any already exist
that match whatever criteria you are using to determine existence, such as
name.

You can filter the Items collections on the MessageClass property.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top