Outlook VBA: Add to Distribution List

dhancy

Board Regular
Joined
Jul 10, 2013
Messages
120
Office Version
  1. 2016
Platform
  1. Windows
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
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,214,926
Messages
6,122,306
Members
449,079
Latest member
juggernaut24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top