Outlook / Exchange - 如何以编程方式导出通讯组列表中的用户?

时间:2008-11-18 14:25:05

标签: c# email outlook exchange-server office-automation

如何使用代码从Outlook中的通讯组列表中导出所有名称和电子邮件地址?我可以访问Outlook 2000或Outlook 2007客户端。理想情况下,我希望代码在C#中。

2 个答案:

答案 0 :(得分:1)

我意识到你问过c#,但http://www.microsoft.com/technet/scriptcenter/resources/officetips/may05/tips0524.mspx中的以下脚本可能有用。

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

答案 1 :(得分:-1)