This post is for Leif Hurst (@leifhurst on Twitter). Leif posted this tweet today:
#outlook 2010 is awesome… all my 2003 and 2007 CDO dependent scripts no longer working… frustrating!! Need to extract headers to email.
With Outlook 2003 and earlier a script had to use CDO (Collaboration Data Objects) to access those item properties that were not exposed by Outlook’s object model. Outlook 2007 changed this by introducing the Property Accessor object. This is a built-in object that allows a script to retrieve unexposed item properties without CDO. The function below takes a mail item and returns the internet headers as a string.
Function GetInetHeaders(olkMsg As Outlook.MailItem) As String ' Purpose: Returns the internet headers of a message.' ' Written: 4/28/2009' ' Author: BlueDevilFan' ' Outlook: 2007' Const PR_TRANSPORT_MESSAGE_HEADERS = "http://schemas.microsoft.com/mapi/proptag/0x007D001E" Dim olkPA As Outlook.PropertyAccessor Set olkPA = olkMsg.PropertyAccessor GetInetHeaders = olkPA.GetProperty(PR_TRANSPORT_MESSAGE_HEADERS) Set olkPA = Nothing End Function