Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 specific 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.

like image 676
Yiftizur Avatar asked Oct 11 '22 23:10

Yiftizur


1 Answers

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));
like image 170
Mike Avatar answered Oct 31 '22 01:10

Mike