0

我正在尝试以编程方式访问名为 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
4

1 回答 1

0

只要您使用 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>

于 2016-07-03T10:24:35.820 回答