views:

71

answers:

3

Is there a way to extract email address from an Outlook Distribution list via script? I am looking for a way to extract all the email addresses from a Distribution list and output it to a CSV file.

+1  A: 

If you mean through an Exchange server, find a solution with ADSI or LDAP through some MS tech page.

If you mean through Outlook Contacts, use Win32::OLE to get into MAPI and then loop through the contacts.

igelkott
Do you have any examples of using Win32:OLE ?
moorecats
Here's one from a Google search: http://www.unur.com/comp/ppp/perl-win32-ole-outlook-ex1.html
igelkott
A: 

I don't know exactly how to get distribution lists, but this links should help you get started if you want to use vbscript: Programming examples for referencing items and folders in Outlook 2000

Or if you want to get distribution lists from Exchange rather than Outlook you might be able to use EWS: HOWTO: EWS: Consume Exchange Web Service from VBScript

ho1
A: 

A few notes in VBScript:

Dim olApp ''Outlook.Application
Dim olMapi ''Outlook.NameSpace
Dim olFolder ''Outlook.MAPIFolder
Dim olItems ''Outlook.Items

olFolderContacts = 10

Set olApp = CreateObject("Outlook.Application")
Set olMapi = olApp.GetNamespace("MAPI")
Set olFolder = olMapi.GetDefaultFolder(olFolderContacts)
Set olItems = olFolder.Items

For i = 1 To olItems.Count
s = s & olItems(i).FullName & Chr(09) & olItems(i).Email1Address
Next 

MsgBox s
End Function

Here is a list of fields for contacts: http://support.microsoft.com/kb/313802

Remou