View Single Post
  #4  
Old October 13th 06, 08:22 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Nested distribution lists

Actually, there's another way to do this without creating a dummy e-mail.
This code illustrates retrieving a DL named "TestDistributionList" and adding
another existing DL named "AnotherDistributionList" to it:

Dim objNS As Outlook.NameSpace
Dim objDL As Outlook.DistListItem
Dim objContacts As Outlook.MAPIFolder
Dim objR As Outlook.Recipient

Set objNS = Application.GetNamespace("MAPI")
Set objContacts = objNS.GetDefaultFolder(olFolderContacts)
Set objDL = objContacts.Items("TestDistributionList")
Set objR = objNS.CreateRecipient("AnotherDistributionList")

objR.Resolve
objDL.AddMember objR
objDL.Save

Set objDL = Nothing
Set objNS = Nothing
Set objContacts = Nothing
Set objR = Nothing

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Hal" wrote:

what do you mean pass it to ... do I set distributionlist =
mailitem.receipient ?

"Eric Legault [MVP - Outlook]" wrote:

Create a dummy e-mail message and address it to the DL you want to nest.
Then retrieve that DL's Recipient object from the MailItem.Recipients
collection and pass it to the DistributionList.AddMember method.

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Hal" wrote:

I know how to make a new DL and add users to a DL via vba but how do I make a
nested distribution list ?

Regards

Ads