Export DL members to Excel CSV with Outlook VBA

M

mac7attack

Hello all,

I need to write a VBA script that will export the members of a Exchange
Distribution List into a CSV (or a semicolon delimited txt). I did find
the following code snippet from Microsoft that runs in a cmd shell.
Could someone please help me convert this into a valid VBA script to
export the list in Excel?


I am running Outlook 2003 in a Windows 2000 enviroment with Exchange
2000. (don't ask me why.)

Thanks
Matt

[Code}

Const olFolderContacts = 10


Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")

Set colContacts = objNamespace.GetDefaultFolder(olFolderContacts).Items
intcount = colContacts.Count

For i = 1 To intcount
If TypeName(colContacts.Item(i)) = "DistListItem" Then
Set objDistList = colContacts.Item(i)
Wscript.Echo objDistList.DLName
For j = 1 To objDistList.MemberCount
Wscript.Echo objDistList.GetMember(j).Name & " -- " & _
objDistList.GetMember(j).Address
Next
Wscript.Echo
End If
Next

[End Code}
 

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