How to Import Distribution List members from multiple accounts outlook 2010 VBA

rafeemd

New Member
Joined
Oct 18, 2011
Messages
12
Hi All experts, require your help for an issue.

I have a task to import the members of Distribution list. I am using Outlook 2010 and configured 2 mails.

I am able to find and get the members of Distribution List from the first mail box/GAL. The same code is not working to search the second Mail GAL. If I manually searched the outlook am able to see that DL but from the code.

Could someone please help on this, i tried a lot and it is giving me nuts.

The below code works for first Mail box GAL and it is always searching in that GAL only.

Sub GetDGMembers()

Dim olApp As Outlook.Application
Dim olNS As Outlook.Namespace
Dim olAL As Outlook.AddressList
Dim olEntry As Outlook.AddressEntry
Dim olMember As Outlook.AddressEntry
Dim lMemberCount As Long
Dim objMail As Outlook.MailItem

Set olApp = Outlook.Application
Set olNS = olApp.GetNamespace("MAPI")
Set olAL = olNS.AddressLists("Global Address List")

Set objMail = olApp.CreateItem(olMailItem)

' enter the list name
Set olEntry = olAL.AddressEntries(".DL Support")

' get count of dist list members
lMemberCount = olEntry.Members.Count

' loop through dist list and extract members
Dim i As Long
For i = 1 To lMemberCount
'my process update in sheet
Next i


End Sub

Please suggest how to access the second GAL to get DL members.

Appreciate your support help in this regard.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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