我已经制定了下面的代码,它的工作原理:如何从EWS的传入电子邮件中获得UniqueBody?
private void OnEvent(object sender, NotificationEventArgs args)
{
StreamingSubscription sub = args.Subscription;
foreach (NotificationEvent notification in args.Events)
{
switch (notification.EventType)
{
case EventType.NewMail:
if (notification is ItemEvent)
{
ItemEvent item = (ItemEvent)notification;
EmailMessage message = EmailMessage.Bind(service, item.ItemId);
string fAddress = message.From.Address;
string subject = message.Subject;
string body = message.Body.Text;
string tAddress = message.ToRecipients[0].Address;
//and so on...
}
break;
}
}
}
但是,如果我尝试设置“身体”等于UniqueBody像这样...
string body = message.UniqueBody.Text;
的错误说出来,“您必须在读取其值之前加载或分配此属性。”我希望UniqueBody能够开箱即用,这意味着我不需要解析一封新邮件来获取我关心的新细节。我假设有一些我很想念的东西。有任何想法吗?