如何使用EWS托管API访问Exchange GAL MailContact属性Notes?

时间:2016-07-01 15:56:07

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

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

这是我的代码:

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

1 个答案:

答案 0 :(得分: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>

相关问题