【问题标题】:How to access Exchange GAL MailContact property Notes using EWS Managed API?如何使用 EWS 托管 API 访问 Exchange GAL MailContact 属性注释?
【发布时间】:2016-07-03 18:24:35
【问题描述】:

我正在尝试以编程方式访问名为 Notes 的 Exchange 全局地址列表联系人属性(如此处 -> GAL Contact - Notes )。我在我的 Visual Studio(C# 编程语言)应用程序中使用 EWS 托管 API。我认为我的代码逻辑还可以。也许 nr.Contact.Notes 不是实现这一目标的正确选择。我将衷心感谢您的帮助。提前谢谢!

这是我的代码:

NameResolutionCollection nrCol = service.ResolveName("SMTP:", ResolveNameSearchLocation.DirectoryOnly, true);
            foreach (NameResolution nr in nrCol)
            {
                if (nr.Contact.Notes == "mail_user")
                {
                    Console.WriteLine("^^^^^^^DO SOMETHING^^^^^^^");
                } // end of if (nr.Contact.Notes == "mail_user")


            } // end of foreach

【问题讨论】:

    标签: c# visual-studio exchange-server ews-managed-api gal


    【解决方案1】:

    只要您使用 Exchange 2010 SP2 或更高版本,您就可以在 Resolve 名称中使用 ContactDataShape 重载,例如

        PropertySet AllProps = new PropertySet(BasePropertySet.FirstClassProperties);
        NameResolutionCollection ncCol = service.ResolveName("User@domain.com", ResolveNameSearchLocation.DirectoryOnly, true, AllProps);
        foreach (NameResolution nr in ncCol)
        {
            Console.WriteLine(nr.Contact.Notes);
        }
    

    产生类似 XML 的

      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Header>
          <t:RequestServerVersion Version="Exchange2013_SP1" />
        </soap:Header>
        <soap:Body>
          <m:ResolveNames ReturnFullContactData="true" SearchScope="ContactsActiveDirectory" ContactDataShape="AllProperties">
            <m:UnresolvedEntry>user@domain.com</m:UnresolvedEntry>
          </m:ResolveNames>
        </soap:Body>
      </soap:Envelope>

    【讨论】:

    • 嗨,格伦,谢谢你的帖子。但我看不出我的代码和你的代码有什么区别。唯一的区别是使用 PropertySet AllProps。这是我的问题的关键信息吗?马托
    • 是的,看看它生成的跟踪,确保在请求中设置了 ContactDataShape="AllProperties"。这需要 2010 SP2 才能工作。 (顺便说一句,您应该先尝试代码,然后围绕获得的结果提出问题)。
    • 现在可以用了,非常感谢!!!我不知道如何处理那个 XML 文件 -> 甚至不知道在哪里可以找到它。对我来说重要的是PropertySet AllProps = new PropertySet(BasePropertySet.FirstClassProperties)。再次感谢。 M.
    猜你喜欢
    • 2016-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-04
    • 2017-12-22
    • 2013-03-11
    • 2015-03-12
    • 1970-01-01
    相关资源
    最近更新 更多