0

I am trying to programically access Exchange Global Address List Contact property called Notes (like here -> GAL Contact - Notes ). I am using EWS Managed API in my Visual Studio (C# programming language) application. I think the logic of my code is OK.. maybe nr.Contact.Notes is not the right option how to achieve that. I would really appreciate your help. Thx in advance!

Here's my code:

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
Mato Skok
  • 29
  • 1
  • 8

1 Answers1

0

As long as your using Exchange 2010 SP2 or greator then you can use the ContactDataShape overload in Resolve name eg

    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);
    }

which produces XML like

  <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>
Glen Scales
  • 20,495
  • 1
  • 20
  • 23
  • Hi Glen, thank you for your post. But I can't see any difference between mine and yours code. The only difference is to use PropertySet AllProps. Is that the key information for my problem? Mato – Mato Skok Jul 03 '16 at 21:53
  • Yes look at the trace it generates it ensure that the ContactDataShape="AllProperties" get set in the request. This requires 2010 SP2 to work. (BTW you should try the code first then ask questions around the results you get). – Glen Scales Jul 03 '16 at 23:17
  • It works now, thank you very much!!! I don't know how to eork with that XML file -> even dont know where to find it. The important thing for me was that `PropertySet AllProps = new PropertySet(BasePropertySet.FirstClassProperties)`. Thx again. M. – Mato Skok Jul 04 '16 at 10:03