0

With an e-mail open in Outlook with OutlookSpy installed, I found the headers of the e-mail at:

OutlookSpy > IMessage > GetProps > PR_TRANSPORT_MESSAGE_HEADERS_W  (the last property in the list)

That is a MAPI property and I don't see any corresponding property in the Outlook Object Model. I figure the headers have to be somewhere in the model. Where are they?

NewSites
  • 1,402
  • 2
  • 11
  • 26

2 Answers2

0

You can retrieve any MAPI property (well, almost) using MailItem.PropertyAccessor.GetProperty. The DASL property name (OutlookSpy shows it) for PR_TRANSPORT_MESSAGE_HEADERS_W is "http://schemas.microsoft.com/mapi/proptag/0x007D001F"

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • Yeah, but are the headers actually not included in the Outlook Object Model? – NewSites May 25 '23 at 20:41
  • The Outlook object model doesn't provide all the properties available via Extended MAPI. – Eugene Astafiev May 25 '23 at 20:53
  • There are quite a few things not included in OOM. That is why MS exposed `MailItem.PropertyAccessor` in Outlook 2007. That property will not be always present - it is only available on messages received from SMTP. Not on sent messages, and not on messages received from other EX mailboxes. – Dmitry Streblechenko May 25 '23 at 21:00
0

Not all properties are available in the Outlook object model. Lowl-level properties are available using the PropertyAccessor.GetProperty method which returns an Object that represents the value of the property specified by SchemaName. For getting transport headers you may use the following code:

Sub DemoPropertyAccessorGetProperty() 
 Dim PropName, Header As String 
 Dim oMail As Object 
 Dim oPA As Outlook.PropertyAccessor 
 'Get first item in the inbox 
 Set oMail = _ 
 Application.Session.GetDefaultFolder(olFolderInbox).Items(1) 
 'PR_TRANSPORT_MESSAGE_HEADERS 
 PropName = "http://schemas.microsoft.com/mapi/proptag/0x007D001E" 
 'Obtain an instance of PropertyAccessor class 
 Set oPA = oMail.PropertyAccessor 
 'Call GetProperty 
 Header = oPA.GetProperty(PropName) 
 Debug.Print (Header) 
End Sub

But in some cases you would need to use Extended MAPI for getting low-level properties because the OOM applies its own restrictions to them.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45