I am trying to fetch extended properties for a exchange user who is logged in Outlook.
Here is my code snippet,but the extended-properties collection has no results.
private string fetchDetailsFromAD() { //get currently logged in user in OUTLOOK string email_from=null; Outlook.AddressEntry currentUser = Globals.ThisAddIn.Application.Session.CurrentUser.AddressEntry; foreach (Microsoft.Office.Interop.Outlook.Account acct in Globals.ThisAddIn.Application.Session.Accounts) { if (acct.CurrentUser.Address == currentUser.Address) { email_from = acct.SmtpAddress; break; } } service.Credentials = new NetworkCredential("han@zepto.com.my", "abcd1234!"); // Look up the user's EWS endpoint by using Autodiscover. service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx"); Contact contact = null; try { NameResolutionCollection allContacts = service.ResolveName(email_from, ResolveNameSearchLocation.DirectoryOnly, true); if (allContacts.Any()) { contact = allContacts[0].Contact; } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Error in GetContactInfo(): "+ ex.Message); //throw; return ""; } return contact.JobTitle; }
So I have Contact object which has ExtendedProperties,but it is an empty collection.
Please let me know how could I fetch them.
For this user I have set CustomAttrribute10 as per attached image.
Point5Nyble