export all addresses in distribution list

A

abbarition

I am used to coding in other Office programs, but I am
unfamiliar with the Outlook objects so I'm not sure where
to start. I need to write a code that will export the
name and email address of every person in several
distribution lists to Excel. There will be over 60
distribution lists, but they will all have the same
prefix. Is there a way for me to look through all my
distribution lists where the name starts with my prefix
and then get the name and email of each person in the
list? (I already have code that will open Excel and add
this information into the spreadsheet.)

Thanks in advance!
 
M

Michael Bauer

Hi,

for OL you can find all objects, methods etc. in the object browser
(F2), too.

Because the Like operator isn´t supported by the Find method, you need
to iterate through the folder items with For-Each e.g.:

Dim obj As Object
Dim oDl as Outlook.DistListItem
Dim oItems as Outlook.Items
Set
oItems=Application.GetNameSpace("Mapi").GetDefaultFolder(olFolderContact
s).Items
For Each obj in oItems
If TypeOf obj Is Outlook.DistListItem Then
set oDl = obj
....
Endif
Next

If you have checked the subject, then you can use the MemberCount
property and GetMember function to retrieve a Recipient object for each
member which contains the address and name.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top