Search code examples
c#winformsoutlookoutlook-2010

Read Undelivered email body in C# windows form


I am developing one tool to keep track of emails and would like to trace the emails undelivered to sender. I dont want to use any third party tool or any external reference

What I have tried? -To read report Item but Body is in Chinese like language -Googled on some solutions but nothing is working i.e. solution is related to

//PR_TRANSPORT_MESSAGE_HEADERS link to get property name "http://schemas.microsoft.com/mapi/proptag/0x0C1A001F" outlook PropertyAccessor class

PropName link is not working anymore.

Could anyone here please help me I would like to get from which sender the email delivery is failed.

Thank you in advance.


Solution

  • The PR_TRANSPORT_MESSAGE_HEADERS property contains the same Diagnostic information shown in the body. You just need to read it using the PropertyAccessor class and parse the string with From and To entries.

      Outlook.PropertyAccessor oPA = reportItem.PropertyAccessor;
      string transportHeaders = (string)oPA.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x007D001E");