我已經制定了下面的代碼,它的工作原理:如何從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能夠開箱即用,這意味着我不需要解析一封新郵件來獲取我關心的新細節。我假設有一些我很想念的東西。有任何想法嗎?