1

I am using the below code to read the mails from my inbox using ews. I am able to read Subject etc. But how to read custom field value?

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Credentials = new NetworkCredential("username", "password", "domain"); 
service.Url = new Uri("https://server/ews/exchange.asmx"); 
FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, new ItemView(100));

foreach (Item item in findResults.Items)
{
    string str=item.Subject;
    foreach (ExtendedProperty extendedProperty in item.ExtendedProperties)
    { }
}

I tried item.ExtendedProperties. But the count is always zero. Can any one tell me how to read the custom field value?

Thanks in advance

competent_tech
  • 44,465
  • 11
  • 90
  • 113
user1003676
  • 87
  • 1
  • 3
  • 9

1 Answers1

0

According to this MSDN article, you need to add a property set for the extended properties that you want to retrieve to the ItemView parameter of the FindItems method.

For example, your line:

FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, new ItemView(100));

becomes:

ItemView view = new ItemView(100);

Guid MyPropertySetId = new Guid("{C11FF724-AA03-4555-9952-8FA248A11C3E}");

view.PropertySet = new PropertySet(BasePropertySet.IdOnly, ItemSchema.Subject, extendedPropertyDefinition);

FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, view);
competent_tech
  • 44,465
  • 11
  • 90
  • 113