如何读取自定义字段值 [英] How to read custom field value

查看:119
本文介绍了如何读取自定义字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码使用ews从我的收件箱中读取邮件.我能够读取Subject等.但是如何读取自定义字段值?

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)
    { }
}

我尝试了item.ExtendedProperties.但是计数始终为零.谁能告诉我如何读取自定义字段值?

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

预先感谢

推荐答案

根据

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.

例如,您的行:

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

这篇关于如何读取自定义字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆