Exchange EWS Managed API - Undelivarable mail notification does not have the DateTimeReceived property
When finding items from a Exchange 2010 Server journaling inbox
, there are some notifications on undelivered mails.
When processing these emails and trying to read the DateTimeReceived
property, I get an ServiceObjectPropertyException
with the error:
You must load or assign this property before you can read its value.
Is there a way of identifying such emails, or loading the DateTimeReceived
property (even it will be null)?
My Code is something like this:
FindItemsResults<Item> mails = folder.FindItems(searchConditions, countConstraint);
foreach (Item item in mails)
{
EmailMessage email = (EmailMessage)item;
email.Load();
DateTime receivedTime = email.DateTimeReceived;
....
}
Those emails are from a journaling mailbox that has a copy of monitored mailbox every email sent to it.
The 开发者_如何学Cspecific emails that do not have this property, are notifications about emails sent from one of those mailboxes, but could not be delivered.
Through MFCMapi I was able to view the message, and the PR_MESSAGE_DELIVERY_TIME
property is set.
I don't think DateTimeReceived
is considered a first class property so you need to load your email with specific properties.
email.Load(new PropertySet(ItemSchema.DateTimeReceived));
try ((MailItem)item).DateTimeReceived
- for reference see
- http://gsexdev.blogspot.com/2011/08/using-allitems-search-folder-from.html
- http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/8c71ace4-43d2-4ba2-88f2-16376dad828f
- http://msdn.microsoft.com/en-us/library/microsoft.exchange.data.transport.mailitem.datetimereceived%28v=EXCHG.80%29.aspx
精彩评论