Невозможно получить первый адрес электронной почты для отображения. Все записи отображаются так:
«Данный ключ отсутствует в словаре». Определенно есть адреса электронной почты, связанные с контактами. Вот код
....
static void Reademail()
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);
service.UseDefaultCredentials = true;
service.AutodiscoverUrl("validaddress@ddd.com");
// Get the number of items in the contacts folder. To limit the size of the response, request only the TotalCount property.
ContactsFolder contactsfolder = ContactsFolder.Bind(service,WellKnownFolderName.Contacts,new PropertySet(BasePropertySet.IdOnly, FolderSchema.TotalCount));
// Set the number of items to the number of items in the Contacts folder or 50, whichever is smaller.
int numItems = contactsfolder.TotalCount < 50 ? contactsfolder.TotalCount : 50;
// Instantiate the item view with the number of items to retrieve from the Contacts folder.
ItemView view = new ItemView(numItems);
// To keep the request smaller, request only the display name property.
view.PropertySet = new PropertySet(BasePropertySet.IdOnly, ContactSchema.DisplayName);
// Retrieve the items in the Contacts folder that have the properties that you selected.
FindItemsResults<Item> contactItems = service.FindItems(WellKnownFolderName.Contacts, view);
// Display the list of contacts.
foreach (Item item in contactItems)
{
if (item is Contact)
{
Contact contact = item as Contact;
Console.Write(contact.DisplayName + " ");
try
{
Console.WriteLine(contact.EmailAddresses[EmailAddressKey.EmailAddress1].Name);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
Console.ReadKey();
}
.....