简体   繁体   English

如何读取自定义字段值

[英]How to read custom field value

I am using the below code to read the mails from my inbox using ews. 我正在使用以下代码使用ews从我的收件箱中读取邮件。 I am able to read Subject etc. But how to read custom field value? 我能够读取Subject等。但是如何读取自定义字段值?

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. 我尝试了item.ExtendedProperties。 But the count is always zero. 但是计数始终为零。 Can any one tell me how to read the custom field value? 谁能告诉我如何读取自定义字段值?

Thanks in advance 提前致谢

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. 根据此MSDN文章 ,您需要将要检索的扩展属性的属性集添加到FindItems方法的ItemView参数。

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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM