Mail Header Information

G

Guest

How can I access the header information in an incoming e-mail via VBA?

I want to draw out the "'Received: from c1m2.emaildefenseservice.com
(c1m2.emaildefenseservice.com [216.40.36.34])" line, from the header info
copied below, so that I can generate a list of domain names we received
mail from. Is this possible. If so what VBA code should I use to access the
header information? Notice the domain name in the "Recieved from" is
different than Domain in the return path of the senders name.

Thank you in advance for any assistance.
Tom


I am receiving the following:
'Return-Path: <[email protected]>
'Received: from c1m2.emaildefenseservice.com (c1m2.emaildefenseservice.com
[216.40.36.34])
' by mail.viclink.com (8.11.7/8.11.7) with SMTP id i4OJZGm33527;
' Mon, 24 May 2004 12:35:16 -0700 (PDT)
'Date: Mon, 24 May 2004 12:35:16 -0700 (PDT)
'From: ivy_rowe@ hotmail.com
'Message-Id: <[email protected]>
'Received: from h000094c76858.ne.client2.attbi.com [24.131.167.237] (HELO
h000094c76858.ne.client2.attbi.)
' by c1m2.emaildefenseservice.com (mxl_mta-1.3.7-29) with SMTP id
b6e42b04.32104.119.c1m2;
' Mon, 24 May 2004 15:35:07 -0400 (EDT)
'MIME-Version: 1.0
'Subject: Now
'x -Originating - IP: [243.116.52.188]
'x -Originating - Email: [[email protected]]
'x -Sender: jburns@ freelin - wade.com
'Received: from 172.201.86.102 by by6fracture.ear0.hotmail.com with
HTTP;Mon, 24 May 2004 02:48:52 GMT
'x -MX - Spam: exempt
'X-MX-MAIL-FROM: <[email protected]>
'x -MX - Source - IP: [24.131.167.237]
'X-RAVMilter-Version: 8.4.3(snapshot 20030217) (mail.viclink.com)
'X-UIDL: SN@!!FEm!!S0H"!>Pb"!
 
K

Ken Slovak - [MVP - Outlook]

You can access that information, but not by using the Outlook object model.
You would have to use CDO 1.21 (optional installation with Outlook 2000 and
later and subject to the security prompts when accessing headers in secure
versions of Outlook) or Redemption (3rd party library located at
www.dimastr.com/redemption) or Extended MAPI (coded only in C++ or Delphi
and very hard to learn). In addition, the header information would come as
one long string and would have to be parsed by your code to find the
particular header property you want.

To see a CDO 1.21 example of getting header information see
http://www.slovaktech.com/code_samples.htm#InternetHeaders
 
G

Guest

Thx for the direction Ken,

Followup question now if you don't mind. I copied and pasted the code from
your site into a function in a module in an VBA project within my Outlook
2000 (W2K machine as well). I added a reference to Microsoft CDO for Windows
2000 library (CDOsys.dll) and Microsoft CDO for NTS 1.2 Library
(CDOnts.dll). These are the only two I appeared to have available to me.
However the code hangs at the line "Dim objCDO As MAPI.Session" with an
error message "Compile Error: User-Defined type not defined". It appears
that the MAPI object is not available to me as of yet. The system doesn't
see anthing other than MAPIFolders in the type ahead feature.

Is this something specific to the CDO 1.21 (CDO.DLL) reference or am I
missing something else?

Tom


Ken Slovak - said:
You can access that information, but not by using the Outlook object model.
You would have to use CDO 1.21 (optional installation with Outlook 2000 and
later and subject to the security prompts when accessing headers in secure
versions of Outlook) or Redemption (3rd party library located at
www.dimastr.com/redemption) or Extended MAPI (coded only in C++ or Delphi
and very hard to learn). In addition, the header information would come as
one long string and would have to be parsed by your code to find the
particular header property you want.

To see a CDO 1.21 example of getting header information see
http://www.slovaktech.com/code_samples.htm#InternetHeaders




No Spam said:
How can I access the header information in an incoming e-mail via VBA?

I want to draw out the "'Received: from c1m2.emaildefenseservice.com
(c1m2.emaildefenseservice.com [216.40.36.34])" line, from the header info
copied below, so that I can generate a list of domain names we received
mail from. Is this possible. If so what VBA code should I use to access the
header information? Notice the domain name in the "Recieved from" is
different than Domain in the return path of the senders name.

Thank you in advance for any assistance.
Tom


I am receiving the following:
'Return-Path: <[email protected]>
'Received: from c1m2.emaildefenseservice.com (c1m2.emaildefenseservice.com
[216.40.36.34])
' by mail.viclink.com (8.11.7/8.11.7) with SMTP id i4OJZGm33527;
' Mon, 24 May 2004 12:35:16 -0700 (PDT)
'Date: Mon, 24 May 2004 12:35:16 -0700 (PDT)
'From: ivy_rowe@ hotmail.com
'Message-Id: <[email protected]>
'Received: from h000094c76858.ne.client2.attbi.com [24.131.167.237] (HELO
h000094c76858.ne.client2.attbi.)
' by c1m2.emaildefenseservice.com (mxl_mta-1.3.7-29) with SMTP id
b6e42b04.32104.119.c1m2;
' Mon, 24 May 2004 15:35:07 -0400 (EDT)
'MIME-Version: 1.0
'Subject: Now
'x -Originating - IP: [243.116.52.188]
'x -Originating - Email: [[email protected]]
'x -Sender: jburns@ freelin - wade.com
'Received: from 172.201.86.102 by by6fracture.ear0.hotmail.com with
HTTP;Mon, 24 May 2004 02:48:52 GMT
'x -MX - Spam: exempt
'X-MX-MAIL-FROM: <[email protected]>
'x -MX - Source - IP: [24.131.167.237]
'X-RAVMilter-Version: 8.4.3(snapshot 20030217) (mail.viclink.com)
'X-UIDL: SN@!!FEm!!S0H"!>Pb"!
 
K

Ken Slovak - [MVP - Outlook]

Both are the wrong versions of CDO. You want CDO 1.21 (CDO.DLL). As I
mentioned, it's an optional installation for Outlook 2000 and later so it's
probably not installed on your system. Use Add/Remove Programs in the
Control Panel to change your Outlook installation to include Collaboration
Data Objects (CDO). Make sure to have your Office CD handy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top