Outlook VBA: Add to Distribution List

dhancy

Board Regular
Joined
Jul 10, 2013
Messages
100
I am so glad this site allows questions on other applications too. It's been super helpful with Excel, but now I have questions about Outlook VBA as well.

I have many questions, but for starters, I am trying to add email address to (and delete from) to distribution list in the GAL.

The code snippet here successfully finds my distribution list and prints all the members:

VBA Code:
Dim olEntry As Outlook.AddressEntry
Dim olDL As Outlook.ExchangeDistributionList
Dim i As Long

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

For i = 1 To olEntry.Members.Count
    Debug.Print olDL.Members.Item(i), olEntry.Members.Item(i).GetExchangeUser.PrimarySmtpAddress
Next i


But how do I add to this list (or delete from it)? I have searched online but haven't found anything of value yet.

Thanks for your help!


Dennis
 

Some videos you may like

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Watch MrExcel Video

Forum statistics

Threads
1,119,220
Messages
5,576,807
Members
412,748
Latest member
MikeyP14
Top