我需要从文件或数据库中读取包含姓名和电子邮件的记录,并将它们添加到现有的 Oulook 分发列表(来自私人联系人,而不是来自 GAL)。
我刚刚看到了使用 LINQ to DASL 从 OL 读取的示例,这些示例用于处理邮件和约会,但我不知道如何列出 dist 列表的内容:
private static void GetContacts()
{
Outlook.Application app = new Outlook.Application();
Outlook.Folder folder = (Outlook.Folder)app.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
var distLists = from item in folder.Items.AsQueryable<MyDistList>()
where item.DLName == "My Dist List"
select item.Item;
var builder = new StringBuilder();
foreach (var list in distLists)
{
builder.AppendLine(list.DLName);
foreach (var item in list.Members)
{
// can't figure out how to iterate through the members here
// compiler says Object doesn't have GeNumerator...
}
}
Console.WriteLine(builder.ToString());
Console.ReadLine();
}
一旦我可以阅读成员,我就需要能够添加新成员,这更加棘手。任何帮助,将不胜感激。