amber
amber

Reputation: 1137

Retrieving original headers using Outlook Redemption

I'm working on a piece of Outlook automation that takes mail placed in a specific folder and exports it as an RFC822 formatted mail message. This output file will then be fed to the SpamAssassin tool sa-learn.exe.

For Each oItem In oFolder.Items
    If TypeOf oItem Is RDOMail Then
        Set oMailItem = oItem

        ' Deptermine the fully qualified path to save the file
        sFilePath = GetFilePath(oMailItem, "//Mailbox/SpamAssassin/Spam") 

        'Save the RFC822 format message
        oMailItem.SaveAs sFilePath, rdoSaveAsType.olRFC822

        DoEvents

        oMailItem.UnRead = False
        oMailItem.Delete
    End If
    DoEvents 'Let the Outlook UI thread breathe a bit
Next 'for each

Here are the message headers from a message saved using this code with redacted e-mail addresses.

From: "Swift Learning" <**********@***.*************.***>
To: <*****@********.***>
Subject: Foreign Languages are easily learned in this program
Date: Tue, 31 Jul 2012 10:11:38 -0700
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: multipart/alternative;
    boundary="----=_NextPart_000_13AE_01CD6F0A.C9624870"
X-Mailer: Microsoft Outlook 14.0
Thread-Index: AQF4Lq/07oPqx1sKGPa5FKQSalUQXg==

What's missing from this are the relay headers that should look something like this.

Received: from [216.104.163.151] by mail.clarkzoo.org (ArGoSoft Mail Server .NET v.1.0.8.4) with ESMTP (EHLO smtp02-forward-1.daemonmail.net)
    for <*****@*********.***>; Tue, 31 Jul 2012 12:36:25 -0700
Received: from mxw03.daemonmail.net (unknown [216.104.161.13])
    by smtp02-forward-1.daemonmail.net (Postfix) with ESMTP id 4447681FDB;
    Tue, 31 Jul 2012 12:18:01 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1])
    by mxw03.daemonmail.net (Postfix) with ESMTP id 748CF6A0DD
    for <***@******************.***>; Tue, 31 Jul 2012 12:17:52 -0700 (PDT)

How can I capture those relay headers?

Update:

Looking into this further, the raw headers as stored in the MailItem in Outlook are radically different from the RFC822 format as saved by Redemption.

Here's a side by side comparion.

Raw headers from the Properties dialog in Outlook.

Received: from [108.174.54.7] by mail.clarkzoo.org (ArGoSoft Mail Server .NET v.1.0.8.4) with ESMTP (EHLO upgraded.the-ameri-credit-review.com)
    for <*****@********.***>; Wed, 01 Aug 2012 07:34:15 -0700
Date: Wed, 1 Aug 2012 09:55:57 -0400
Subject: Your TransUnion, Equifax, and Experian Scores May Have Changed
From: "Credit Check" <[email protected]>
To: <*****@********.***>
Message-ID: <132692318349a4a4158c108651c1428c@upgraded.the-ameri-credit-review.com>
Mime-Version: 1.0
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
SPF-Received: softfail
X-FromIP: 108.174.54.7

The headers from the RFC822 formatted file:

From: "Credit Check" <[email protected]>
To: <*****@********.***>
Subject: Your TransUnion, Equifax, and Experian Scores May Have Changed
Date: Wed, 1 Aug 2012 06:55:57 -0700
Message-ID: <132692318349a4a4158c108651c1428c@upgraded.the-ameri-credit-review.com>
MIME-Version: 1.0
Content-Type: multipart/alternative;
    boundary="----=_NextPart_000_011B_01CD6FC4.403990C0"
X-Mailer: Microsoft Outlook 14.0
Thread-Index: AQIRB+hjg86/OeRgMx9VYijSdeLwhw==

Those headers are only superficially the same.

The better question is how does one capture the original headers of the message?

Upvotes: 3

Views: 1149

Answers (1)

K_M
K_M

Reputation: 386

I know this is an old post but try saving as rdoSaveAsType.olRFC822_Redemption instead of rdoSaveAsType.olRFC822. It seems to preserve all of the headers.

Upvotes: 1

Related Questions