如何使用MAPI获取Outlook联系人组? [英] How to get Outlook contact groups using MAPI?

查看:154
本文介绍了如何使用MAPI获取Outlook联系人组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Outlook 2010中,您可以创建联系人并将其添加到组中.有什么方法可以获取此类组及其中的联系人的列表?这是我访问联系人的方式:

In Outlook 2010, you can create contacts and add them to groups. Is there any way to get the list of such groups and the contacts in them? Here's how I access the contacts:

var outlook = new Outlook.Application().GetNamespace("MAPI");
var folder = outlook.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
foreach (var curr in folder.Items.OfType<Outlook.ContactItem>())
{
    ...
}

是指默认的联系人文件夹,例如联系人"和建议的联系人".

I do not mean default contact folders, such as "Contacts" and "Suggested contacts".

推荐答案

联系人组由

The contact groups are represented by DistListItem Interface. DistListItem interface has MemberCount property and GetMember() method to iterate through the group members.

var outlook = new Application().GetNamespace("MAPI");
var folder = outlook.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
foreach (var curr in folder.Items.OfType<DistListItem>())
{
    Console.WriteLine(curr.DLName);

    for (int memberIdx = 1; memberIdx <= curr.MemberCount; memberIdx++)
    {
        var member = curr.GetMember(memberIdx);
        Console.WriteLine(member.Name);
    }
}

这篇关于如何使用MAPI获取Outlook联系人组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆