I am doing some automation on outlook mail box, previously it was lotus notes.So i am looking for equivalent properties in outlook. The lotus notes mail items has a item named FAILUREREASON
which has the details about why the email is failed such as delivery failure reason etc. This item will be available when the mail is a delivery failure email. So when i loop through mails in inbox i can recognize which mail is a delivery failure email in inbox and which is actual required mail to be processed. But in outlook MailItem object i didn't find any option to get it. I searched for any solutuion but not able to find any. We can search subject for words such as 'failure' but it's not good approach. Can anyone know the property that i need to look or any other approach for the same.
2 Answers
Standard bounce or undeliverable emails are received in Outlook as special items using the REPORT.IPM.Note.NDR message class and are available as a ReportItem object in the Outlook Object Model. You can also read the mail header information via the PR_TRANSPORT_MESSAGE_HEADERS_W MAPI property on any kind of email.
One way of retrieving the value is by using PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x007D001F")
ReportItem
object in Outlook (not related to the MailItem
object) exposes NDR information through the ReportItem.Body
property. On the Extended MAPI level (C++ or Delphi) the properties are stored in the recipient table - you can see the data in OutlookSpy (click IMessage button, go to the GetRecipeintTable tab).
For the MailItem
objects, you can access that information using Recipient.PropetyAccessor.GetProperty
, but ReportItem
object does nto expose the Recipients collection (unlike the MailItem object).
If using Redemption is an option, its ReportItem object (derived from the RDOMail object) and exposes the Recipients collection. You can reopen Outlook's NDR in Redemption and creating an instance of the RDOSession object and calling RDOSession.GetRDOObjectFromOutlookObject method.