views:

1339

answers:

2

How do I export all of the names and email addresses from a distribution list in Outlook using code? I have access to an Outlook 2000 or Outlook 2007 client. Ideally I would like the code to be in C#.

A: 

use outlook component model http://www.dotnetjunkies.ddj.com/Tutorial/2E1EEEAF-C78A-4A38-A830-AC204B12DF83.dcik

Mladen Prajdic
Do you have specific information on how to use the object model to access the distribution list?
BrianLy
+1  A: 

I realize you asked about c#, but the following script from http://www.microsoft.com/technet/scriptcenter/resources/officetips/may05/tips0524.mspx may be of some use.

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
Remou