【问题标题】:using the outlook object model, can i get the fields that i see in the outlook contact使用 Outlook 对象模型,我可以得到我在 Outlook 联系人中看到的字段吗
【发布时间】:2009-11-28 05:23:06
【问题描述】:

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

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

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


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

【问题讨论】:

    标签: c# outlook street-address


    【解决方案1】:

    使用 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();
        }
    }
    

    【讨论】:

    • 我在这里寻找全球通讯录.. 不是您的本地联系人列表
    • Applogies 关于混音。更新了我对全球通讯录的回答。
    【解决方案2】:

    RDO 对你有用吗?它提供了相当多的 Outlook 阻止功能,包括 address data

    RDO & C#

    【讨论】:

      【解决方案3】:

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

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

      【讨论】:

        【解决方案4】:

        正如其他question 所建议的那样,您可能不得不直接访问地址簿下的 LDAP 数据库。

        【讨论】:

        • 这似乎很奇怪,它不会在常规对象模型中公开。 .
        • 我如何找出我的搜索结果中存在哪些 ldap 字段,因为这些似乎都是字符串
        猜你喜欢
        • 2011-02-23
        • 1970-01-01
        • 1970-01-01
        • 2017-07-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-10-23
        • 1970-01-01
        相关资源
        最近更新 更多