Я пытаюсь загрузить и использовать свойства EWS Items. При выполнении моих кодов объект теряет свою ценность. Я загружаю messageId, приложения и тему.
Вот мой код:
'' '
FindItemsResults<Item> items = EwsHelper.GetMails(credentials); //Gets the items from the exchange service object. This method populate FindItemResults. It works.
//Find correct EmailMessage with messageId (mailInput.MessageId is a param to my code to verify that I found the correct mail.
string messageId = mailInput.MessageId;
//The Id.UniqueId can be found. The property is loaded inside of the "EwsHelper.GetMails".
foreach (Item item in items.Where(i => i.Id.UniqueId == messageId))
{
//Here im loading all the properties I need once again. I can verify that the object does have loaded property through the debugger. Everything is fine!
item.Load(new PropertySet(ItemSchema.Subject,
ItemSchema.Id, ItemSchema.Attachments));
if (item == null || !(item is EmailMessage))
throw new Exception();
dynamic fileObj = new ExpandoObject();
//Here the item.Subject (which recently was loaded) is null... Cant figure out why?!
fileObj.Filename = $"{item.Subject.RemoveInvalidFileNameChar()}.msg";
}
' ''