首页 文章

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

提问于
浏览
0

I am trying to programically access Exchange Global Address List Contact property called Notes (喜欢这里 - > 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

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

相关问题