Outlook VBA: Add new member to ExchangeDistributionList

Copper Contributor

Hello,

 

My goal is to add a new member to an Exchange Distribution List.  I have this code so far:

 

Dim olEntry As Outlook.AddressEntry
Dim olDL As Outlook.ExchangeDistributionList

Set olEntry = Application.Session.GetGlobalAddressList.AddressEntries("XYZ")
Set olDL = olEntry.GetExchangeDistributionList

 

I am able to "for loop" my way through this list to print existing members, so I know this code is correct.  I am also able to add new members to it through my regular Outlook screens so I know I have the correct permissions.

 

I want to be able to add (and delete) members to/from this list via VBA code.

 

I've seen sample code along these lines:

 

Set newae = olDL.Members.Add("SMTP", "Jimmy Pena", "jp@somewhere.com")

 

However, when I tried this (along with various combinations), I keep getting the message "bookmark not defined."

 

Can someone point me to the proper syntax to add a new member to this list? 

 

Also, the Outlook object model does not show "Members" as a property of an AddressEntry or an ExchangeDistributionList.  I guess I need some guidance on that as well.

 

Thank you!

 

Dennis

0 Replies