请教高手,在使用ews读取exchange邮件得时候出现的问题

netboygg 2013-09-25 11:16:58
当我的程序要判断读取该邮件得正文的时候报错:

Microsoft.Exchange.WebServices.Data.ServiceObjectPropertyException: You must load or assign this property before you can read its value.
在 Microsoft.Exchange.WebServices.Data.PropertyBag.get_Item(PropertyDefinition propertyDefinition)
在 Microsoft.Exchange.WebServices.Data.Item.get_Body()
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。


代码如下:

foreach (Item item in findResults.Items)
{
list.Add(item.Subject.ToString());
list.Add(item.DateTimeSent.ToShortDateString());
list.Add(item.Id.ToString());

//HTML如果不为空
if (item.Body != null)
{
//html格式的内容
MessageBody body = item.Body;
//读取文本
list.Add(body.Text.ToString());
}

}

在代码中我添加了在网上说的同样报错的解决代码:

FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox,SetFilter(), view);
PropertySet detailedPropertySet = new PropertySet(BasePropertySet.FirstClassProperties, AppointmentSchema.Recurrence);
service.LoadPropertiesForItems(from Item item in findResults select item, detailedPropertySet);

但是还是报一样的错,请问高手有没有解决办法。先谢谢了。
...全文
400 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
wwwarewow 2015-10-09
  • 打赏
  • 举报
回复
item.load();

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧