Created
August 11, 2014 06:08
-
-
Save chakkaradeep/24d4182e7771eef9eaef to your computer and use it in GitHub Desktop.
Office 365 API Contacts - Read Contacts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task<ObservableCollection<MyContact>> GetContacts() | |
{ | |
ObservableCollection<MyContact> myContactList = new ObservableCollection<MyContact>(); | |
//query contacts | |
var contactsResults = await _exchangeClient.Me.Contacts.OrderBy(c=>c.DisplayName).ExecuteAsync(); | |
//fetches the first 50 contacts | |
//default page count is 50 | |
var contacts = contactsResults.CurrentPage.ToList(); | |
//enumerate and build your contact object | |
foreach (var contact in contacts ) | |
{ | |
MyContact myContact = new MyContact(); | |
myContact.Id = contact.Id; | |
myContact.Name = String.Format("{0} {1}", contact.GivenName, contact.Surname); | |
myContact.Email = contact.EmailAddress1; | |
myContact.Picture = await GetContactImage(contact.Id); | |
myContactList.Add(myContact); | |
} | |
return myContactList; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment