How to obtain internet headers from Outlook


I did not find any method to obtain the Internet Headers from a MailMessage that I have retrieved from Outlook.
I have tried both Get Outlook Mail Messages and Get Exchange Mail Messages. I need to get all the details without using the Outlook interface or saving the messages to disk (might contain malware)

Internet Headers Example
From: Media Temple user (
Subject: article: How to Trace a Email
Date: January 25, 2011 3:30:58 PM PDT
Return-Path: <>
Delivery-Date: Tue, 25 Jan 2011 15:31:01 -0700
Received: from ([]:54907) by with esmtp (Exim 4.63) (envelope-from <>) id 1KDoNH-0000f0-RL for; Tue, 25 Jan 2011 15:31:01 -0700
Received: by with SMTP id y22so795146pof.4 for <>; Tue, 25 Jan 2011 15:30:58 -0700 (PDT)
Received: by with SMTP id t17mr3929916rvm.251.1214951458741; Tue, 25 Jan 2011 15:30:58 -0700 (PDT)
Received: by with HTTP; Tue, 25 Jan 2011 15:30:58 -0700 (PDT)
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=+JqkmVt+sHDFIGX5jKp3oP18LQf10VQjAmZAKl1lspY=; b=F87jySDZnMayyitVxLdHcQNL073DytKRyrRh84GNsI24IRNakn0oOfrC2luliNvdea LGTk3adIrzt+N96GyMseWz8T9xE6O/sAI16db48q4Iqkd7uOiDvFsvS3CUQlNhybNw8m CH/o8eELTN0zbSbn5Trp0dkRYXhMX8FTAwrH0=
Domainkey-Signature: a=rsa-sha1; c=nofws;; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=wkbBj0M8NCUlboI6idKooejg0sL2ms7fDPe1tHUkR9Ht0qr5lAJX4q9PMVJeyjWalH 36n4qGLtC2euBJY070bVra8IBB9FeDEW9C35BC1vuPT5XyucCm0hulbE86+uiUTXCkaB 6ykquzQGCer7xPAcMJqVfXDkHo3H61HM9oCQM=
Message-Id: <>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="----=_Part_3927_12044027.1214951458678"
X-Spam-Status: score=3.7 tests=DNS_FROM_RFC_POST, HTML_00_10, HTML_MESSAGE, HTML_SHORT_LENGTH version=3.1.7
X-Spam-Level: ***
Message Body: This is a KnowledgeBase article that provides information on how to find email headers and use the data to trace a email.
1 Like

Hey @c.ciprian,

The details is mostly present in mail header. You can please try the below…

Hope this helps…


Hi @Nithinkrishna,

This returns MailMessage object that does not contain the internet headers with the path followed by the email.

1 Like

Hey @c.ciprian

This can throw some light !

1 Like

This still implies modifications (macros) in Office, that I’m trying to avoid.

1 Like

Yep, But you may need to apply using it in UiPath.

Something like accessing mails from outlook application object, instead of going to get mail activity as it is limited to use mail message object.


1 Like

Could you help me with a sample flow?

kindly note as well and be aware of custom header fields set by the sending application:

1 Like

I am aware. But the elements available do not contain the Internet Headers :frowning:

Hi @c.ciprian ,

i did not tested, but you might need to use Invoke code, and get the desired results.
Anyway, curious if a stable / good solution exist for this.


This is a working example as macro in Outlook. How do I make it work in UiPath?

Sub ViewInternetHeader()
    Dim olItem As Outlook.MailItem, olMsg As Outlook.MailItem
    Dim strheader As String

    For Each olItem In Application.ActiveExplorer.Selection
        strheader = GetInetHeaders(olItem)
        Set olMsg = Application.CreateItem(olMailItem)
        With olMsg 
            .BodyFormat = olFormatPlain
            .Body = strheader
        End With
    Set olMsg = Nothing
End Sub

Function GetInetHeaders(olkMsg As Outlook.MailItem) As String
    ' Purpose: Returns the internet headers of a message.'
    ' Written: 4/28/2009'
    ' Author:  BlueDevilFan'
    ' //
    ' Outlook: 2007'
    Dim olkPA As Outlook.PropertyAccessor
    Set olkPA = olkMsg.PropertyAccessor
    GetInetHeaders = olkPA.GetProperty(PR_TRANSPORT_MESSAGE_HEADERS)
    Set olkPA = Nothing
End Function
1 Like

Using Alphabet activities convert the MailMessage to MailItem, then Invoke Code as below

Dim olkPA As Microsoft.Office.Interop.Outlook.PropertyAccessor
olkPA = MyMessage.PropertyAccessor
MyHeader = olkPA.GetProperty("").ToString
olkPA = Nothing

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.