I need some help on Outlook VBA.
I am trying to write a macro in Outlook for extracting the email address from each individual undeliverables email body.
Th
There is a problem with the ReportItem.Body
property in the Outlook Object Model (present in Outlook 2013 and 2016) - you can see it in OutlookSpy: select an NDR message, click Item button, select the Body property - it will be garbled. Worse than that, once the report item is touched with OOM, Outlook will display the same junk in the preview pane.
The report text is stored in various MAPI recipient properties (click IMessage button in OutlookSpy and go to the GetRecipientTable
tab). The problem is the ReportItem
object does not expose the Recipients collection. The workaround is to either use Extended MAPI (C++ or Delphi) or Redemption (any language) - its RDOReportItem.ReportText
property does not have this problem:
set oItem = Application.ActiveExplorer.Selection(1)
set oSession = CreateObject("Redemption.RDOSession")
oSession.MAPIOBJECT = Application.Session.MAPIOBJECT
set rItem = oSession.GetRDOObjectFromOutlookObject(oItem)
MsgBox rItem.ReportText
You can also use RDOReportItem.Recipients
collection to extract various NDR properties from the recipient table.