none
How do I get a list of contacts using EWS? RRS feed

  • Question

  • I need to populate a drop down list with contacts using EWS.  Is there code available that shows a sample of how to do this?
    Tuesday, November 30, 2010 10:30 PM

Answers

All replies

  • I take it you mean contacts from a Mailbox's contacts folder as apposed to contacts from the Global Address list i would suggest you look at using the EWS managed API http://msdn.microsoft.com/en-us/library/dd637749(EXCHG.80).aspx and then something like

          ContactsFolder cf = ContactsFolder.Bind(service,WellKnownFolderName.Contacts);
          ItemView iv = new ItemView(100);
          FindItemsResults<Item> fiResult = cf.FindItems(iv);
          foreach (Item cn in fiResult.Items) {
            if(cn is Contact){
              Contact cn1 = (Contact)cn;
              Console.WriteLine(cn1.DisplayName);
              Console.WriteLine(cn1.EmailAddresses[EmailAddressKey.EmailAddress1].Address);
          
            }
          
          } 
    
    Cheers
    Glen
    Wednesday, December 1, 2010 1:58 AM
  • Well Glen - its looking like it might need to be the Global Address list.  How does the code above change for the Global Address list?  (we are on Exchange 2007 SP1 if that is important to the answer)

    Wednesday, December 1, 2010 2:14 PM
  • EWS is limited in what it can do with addressbooks it has resolve operations but nothing that will enumerate the GAL its better to use LDAP and System.DirectoryServices to query AD directly something like http://www.c-sharpcorner.com/UploadFile/frankalonzo/GlobalAddressList11262005053740AM/GlobalAddressList.aspx

    Cheers
    Glen

    • Marked as answer by swolff Friday, December 10, 2010 5:20 PM
    Thursday, December 2, 2010 5:34 AM