使用C#从Outlook联系人组而不是联系人列表中检索联系人

时间:2017-07-12 19:21:16

标签: c# outlook

我需要从用户指定的Outlook 2013联系人组中检索电子邮件地址。我在别处找到的这个VBA代码工作得很好,但我需要将它转换为C#。我找到的所有C#示例都从联系人列表而不是用户创建的联系人组中提取地址。任何帮助将不胜感激。

    Public Function GetContactGroupAddresses()
        Dim I As Integer
        Dim AddressList As String
        Dim Group As String
        Dim olApp As Outlook.Application
        Dim myNamespace As Object
        Dim myFolder As Object
        Dim myItem As Object
        Dim WordApp As Object

        AddressList = " "
        Group = "EmailTest"

        Set olApp = New Outlook.Application
        With olApp
            Set myNamespace = .GetNamespace("MAPI")
            Set myFolder = myNamespace.GetDefaultFolder(olFolderContacts)
            Set myItem = myFolder.Items(Group)
            For I = 1 To myItem.MemberCount
                    AddressList = AddressList & myItem.GetMember(I).Address
        End With


        GetContactGroupAddresses = AddressList 

    End Function

0 个答案:

没有答案