Outlook VBA: Add new member to ExchangeDistributionList

%3CLINGO-SUB%20id%3D%22lingo-sub-1618397%22%20slang%3D%22en-US%22%3EOutlook%20VBA%3A%20Add%20new%20member%20to%20ExchangeDistributionList%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1618397%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20goal%20is%20to%20add%20a%20new%20member%20to%20an%20Exchange%20Distribution%20List.%26nbsp%3B%20I%20have%20this%20code%20so%20far%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EDim%20olEntry%20As%20Outlook.AddressEntry%0ADim%20olDL%20As%20Outlook.ExchangeDistributionList%0A%0ASet%20olEntry%20%3D%20Application.Session.GetGlobalAddressList.AddressEntries(%22XYZ%22)%0ASet%20olDL%20%3D%20olEntry.GetExchangeDistributionList%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20able%20to%20%22for%20loop%22%20my%20way%20through%20this%20list%20to%20print%20existing%20members%2C%20so%20I%20know%20this%20code%20is%20correct.%26nbsp%3B%20I%20am%20also%20able%20to%20add%20new%20members%20to%20it%20through%20my%20regular%20Outlook%20screens%20so%20I%20know%20I%20have%20the%20correct%20permissions.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20want%20to%20be%20able%20to%20add%20(and%20delete)%20members%20to%2Ffrom%20this%20list%20via%20VBA%20code.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20seen%20sample%20code%20along%20these%20lines%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3ESet%20newae%20%3D%20olDL.Members.Add(%22SMTP%22%2C%20%22Jimmy%20Pena%22%2C%20%22jp%40somewhere.com%22)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20when%20I%20tried%20this%20(along%20with%20various%20combinations)%2C%20I%20keep%20getting%20the%20message%20%22bookmark%20not%20defined.%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20someone%20point%20me%20to%20the%20proper%20syntax%20to%20add%20a%20new%20member%20to%20this%20list%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlso%2C%20the%20Outlook%20object%20model%20does%20not%20show%20%22Members%22%20as%20a%20property%20of%20an%20AddressEntry%20or%20an%20ExchangeDistributionList.%26nbsp%3B%20I%20guess%20I%20need%20some%20guidance%20on%20that%20as%20well.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDennis%3C%2FP%3E%3C%2FLINGO-BODY%3E
New 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