WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE and Outlook
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get Internet headers Field from Outlook Message


Question:

I'm looking for a way to get the Internet headers Field from an outlook message.

I know you need extended MAPI for this but didn't have much succes to get something work until now.

If you select a message in outlook and run the attached macro it shows this field information.

Couldn't get this translated.

'The code below will browse a collection of mails and displays a message box with the internet headers
'To get the code working
'0) install redemption 'see the link in previous post)
'1) set tools/macros/security to Medium
'2) close OL and restart: accept macros to be fired
'3) Alt F11 to open VBA Editor
'4) Expand Project1, expand Microsoft Outlook Objects; double clcik ThisOutlookSession
'5) in right pane, cut and paste the code below

' =============paste from here

sub iHeaders()
Dim mySelection As Outlook.Selection
Dim utils, MailItem, internetHeadersField, internetHeaders, msgId, MessIdPosStart, MessIdPosEnd
dim itm as object
Set utils = CreateObject("Redemption.MAPIUtils")
Set mySelection = Application.ActiveExplorer.Selection

If mySelection.Count = 0 Then
   Set mySelection = Nothing
   Exit Sub
End If
for each itm in mySelection
Set MailItem = itm
internetHeadersField = &H7D001E ' &HC1F001E
internetHeaders = utils.HrGetOneProp(MailItem.MAPIOBJECT, internetHeadersField)
Msgbox internetHeaders 
next
Set utils = Nothing
End Sub

Answer:

Here is my attempt at a translation (requires WB 2004C or newer):


;The code below will browse a collection of mails and displays a message box with the internet headers
;To get the code working
;0) install redemption 
;1) set tools/macros/security to Medium
;2) close OL and restart: accept macros to be fired
;3) Run the code below

myOlApp = CreateObject("Outlook.Application")
;Use this method to return the Explorer object that the user is most likely viewing. 
myExplorer = myOlApp.ActiveExplorer
;Using the Selection Object 
;Use the Selection property to return the Selection collection from the Explorer object. For example:
;mySelectedItems = myExplorer.Selection
mySelection = myExplorer.Selection

utils = CreateObject("Redemption.MAPIUtils")
If mySelection.Count = 0 
mySelection = 0
Exit 
EndIf

foreach itm in mySelection
MailItem = itm
internetHeadersField = 8192030 ;&H7D001E (8192030) or &HC1F001E(203358238)
internetHeaders = utils.HrGetOneProp(MailItem.MAPIOBJECT, internetHeadersField)
Message("internetHeaders", internetHeaders)
MailItem = 0
next

utils = 0
mySelection = 0
myExplorer = 0
myOlApp = 0

Article ID:   W16586
File Created: 2005:02:18:12:21:32
Last Updated: 2005:02:18:12:21:32