我使用以下代码使用ews从我的收件箱中读取邮件。我能够阅读主题等但是如何阅读自定义字段值?
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)
{ }
}
我尝试了item.ExtendedProperties。但计数始终为零。任何人都可以告诉我如何阅读自定义字段值吗?
提前致谢
答案 0 :(得分:0)
根据this MSDN article,您需要将要检索的扩展属性的属性集添加到FindItems方法的ItemView参数中。
例如,您的行:
FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, new ItemView(100));
变为:
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);