2

我可以使用 Outlook 对象模型查看全局通讯簿,但无论如何使用 csharp 的 Outlook 对象模型我可以获得一个人的以下属性:

城市、州、国家/地区别名标题电话

我似乎无法在 AddressEntry 对象上找到这些属性。


编辑:我在这里开始赏金。我使用 LDAP 查询得到了这个工作,但它们太痛苦了。我很震惊 Outlook 在其简单的 api 中不支持这一点。我想看看其他人是否可以正常工作或可以解释/证明为什么 Outlook 不会对此提供支持

4

4 回答 4

5

使用 Microsoft.Office.Interop.Outlook
您需要在 AddressEntry 对象上使用 ExchangeUser 对象和 GetExchangeUser 方法。

using System;
using Microsoft.Office.Interop.Outlook;
static class Program
{
    static void Main(string[] args)
    {
        ExchangeUser oExUser;
        Application app = new Microsoft.Office.Interop.Outlook.Application();
        foreach (AddressList addressList in app.Session.AddressLists)
        {
            if (addressList.Name == "Global Address List")
            {
                foreach (AddressEntry item in addressList.AddressEntries)
                {
                    Console.WriteLine(item.Address);
                    oExUser = item.GetExchangeUser();
                    if (oExUser != null) 
                    {
                        Console.WriteLine(oExUser.FirstName);
                        Console.WriteLine(oExUser.LastName);
                        Console.WriteLine(oExUser.StreetAddress);
                        Console.WriteLine(oExUser.CompanyName);
                        Console.WriteLine(oExUser.Department);
                        Console.WriteLine(oExUser.OfficeLocation);
                        Console.WriteLine(oExUser.JobTitle);
                    }
                    Console.WriteLine();
                }
            }
        }
        Console.Read();
    }
}
于 2009-12-04T02:04:09.763 回答
1

RDO对你有用吗?它提供了相当多的 Outlook 阻止,包括地址数据

RDO & C#

于 2009-11-28T13:35:38.170 回答
1

与必须使用 Outlook 对象模型一样,我建议使用Redemption library。(它会涉及来自 C# 的 COM 互操作,但这不应该是一个问题。)您应该看看RDO(赎回数据对象)库,以及RDOAddressBookandRDOAddressEntry对象。该RDOAddressEntry对象公开了您正在寻找的所有属性。

Redemption 库避免了与 Outlook 安全性相关的问题,并且还允许访问比您在正常 OOM 中公开的更多属性。不幸的是,我无法为您提供一个工作示例来解决您的特定问题,因为我使用该库只是为了处理邮件。但是,在 Redemption 网站上有很多代码示例。

于 2009-12-08T17:36:03.400 回答
0

正如另一个问题中所建议的那样,您可能不得不直接访问地址簿下的 LDAP 数据库。

于 2009-11-28T05:34:28.763 回答