MikeSel
asked on
Extract IP Address From E-mail Header in outlook using VBA
Hello All.
I need to try and get the IP Address of the sender of every mail item received using vba.
I have a 'macro' whichs fires each time an e-mail item is received, and I am able to access the full internet header information using 'Outlook redemption'.
However I would like to strip the senders IP address from the header and place it into another e-mail.
The headers are often quite complicated and may contain more then one IP so I am having touble figuring out how to do this.
An example header:
Microsoft Mail Internet Headers Version 2.0
Received: from netpilot.***.co.uk ([192.168.18.1]) by ***.co.uk with Microsoft SMTPSVC(6.0.3790.0);
Thu, 1 Jun 2006 09:44:10 +0100
Received: by netpilot.***.co.uk (Postfix, from userid 27)
id E089923B8F; Thu, 1 Jun 2006 09:46:08 +0100 (BST)
Received: from mail01-***.cleanport.com (unknown [192.168.0.1])
by netpilot.***.co.uk (Postfix) with ESMTP id 67BCB23B8E
for <mike@***.co.uk>; Thu, 1 Jun 2006 09:46:07 +0100 (BST)
Received: from (unresolved) ([192.168.0.2] HELO=smtpout.***.com)
by mail01-***.uk.cleanport.co m (CleanSMTPd 1.5.5) with ESMTP
id 447F29AF-0 for <mike@***.co.uk>;
Thu, 01 Jun 2006 10:46:03 +0200
Received: from [192.168.0.3] (helo=***.sbs)
by smtpout.***.comwith esmtp (Exim 4.30)
id 1Fliod-0002uX-6k server-id smtp-in2
for mike@***.co.uk; Thu, 01 Jun 2006 09:46:03 +0100
Subject: test
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----_=_NextPart_ 001_01C685 56.A85D344 0"
Date: Thu, 1 Jun 2006 09:37:46 +0100
Message-ID: <3060B2138A85554AA3888557F A3E73E2050 739@adsser ver.ads.sb s>
X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0
content-class: urn:content-classes:messag e
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
Thread-Topic: test
Thread-Index: AcaFVZz9x8Llg/FPEdqSOwBQ2j yEkA==
From: "***" <***@***-uk.org>
To: <mike@***.co.uk>
X-Email-Filter-2B-F6-5F: 3.1.5 netpilot.***.co.uk
X-Spam-Level-2B-F6-5F:
X-Spam-Checker-Version-2B- F6-5F: SpamAssassin 2.64 (2004-01-11) on
netpilot.***.co.uk
X-Spam-Flag-2B-F6-5F: NO
X-Spam-Status-2B-F6-5F: hits=-4.7 tests=BAYES_00,HTML_70_80, HTML_MESSA GE autolearn=no
version=2.64
X-Spam-Key-2B-F6-5F: (-4.7 points in total)
X-Spam-Key-2B-F6-5F: -4.9 BAYES_00 BODY: Bayesian spam probability is 0 to 1%
[score: 0.0000]
X-Spam-Key-2B-F6-5F: 0.1 HTML_70_80 BODY: Message is 70% to 80% HTML
X-Spam-Key-2B-F6-5F: 0.1 HTML_MESSAGE BODY: HTML included in message
X-Spam-Reclassify-2B-F6-5F : https://netpilot.***.co.uk/secure-admin?mod=spamassassin-reclassify&mid=1149151567.1722924367
X-Virus-Checked-2B-F6-5F: 0 Anti-virus engine 4.02.0, released 06 February 2006, 119637 virus identities.
Return-Path: ***@***.org
X-OriginalArrivalTime: 01 Jun 2006 08:44:10.0576 (UTC) FILETIME=[8D4A8D00:01C6855 7]
------_=_NextPart_001_01C6 8556.A85D3 440
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
------_=_NextPart_001_01C6 8556.A85D3 440
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
------_=_NextPart_001_01C6 8556.A85D3 440--
I need to try and get the IP Address of the sender of every mail item received using vba.
I have a 'macro' whichs fires each time an e-mail item is received, and I am able to access the full internet header information using 'Outlook redemption'.
However I would like to strip the senders IP address from the header and place it into another e-mail.
The headers are often quite complicated and may contain more then one IP so I am having touble figuring out how to do this.
An example header:
Microsoft Mail Internet Headers Version 2.0
Received: from netpilot.***.co.uk ([192.168.18.1]) by ***.co.uk with Microsoft SMTPSVC(6.0.3790.0);
Thu, 1 Jun 2006 09:44:10 +0100
Received: by netpilot.***.co.uk (Postfix, from userid 27)
id E089923B8F; Thu, 1 Jun 2006 09:46:08 +0100 (BST)
Received: from mail01-***.cleanport.com (unknown [192.168.0.1])
by netpilot.***.co.uk (Postfix) with ESMTP id 67BCB23B8E
for <mike@***.co.uk>; Thu, 1 Jun 2006 09:46:07 +0100 (BST)
Received: from (unresolved) ([192.168.0.2] HELO=smtpout.***.com)
by mail01-***.uk.cleanport.co
id 447F29AF-0 for <mike@***.co.uk>;
Thu, 01 Jun 2006 10:46:03 +0200
Received: from [192.168.0.3] (helo=***.sbs)
by smtpout.***.comwith esmtp (Exim 4.30)
id 1Fliod-0002uX-6k server-id smtp-in2
for mike@***.co.uk; Thu, 01 Jun 2006 09:46:03 +0100
Subject: test
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----_=_NextPart_
Date: Thu, 1 Jun 2006 09:37:46 +0100
Message-ID: <3060B2138A85554AA3888557F
X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0
content-class: urn:content-classes:messag
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
Thread-Topic: test
Thread-Index: AcaFVZz9x8Llg/FPEdqSOwBQ2j
From: "***" <***@***-uk.org>
To: <mike@***.co.uk>
X-Email-Filter-2B-F6-5F: 3.1.5 netpilot.***.co.uk
X-Spam-Level-2B-F6-5F:
X-Spam-Checker-Version-2B-
netpilot.***.co.uk
X-Spam-Flag-2B-F6-5F: NO
X-Spam-Status-2B-F6-5F: hits=-4.7 tests=BAYES_00,HTML_70_80,
version=2.64
X-Spam-Key-2B-F6-5F: (-4.7 points in total)
X-Spam-Key-2B-F6-5F: -4.9 BAYES_00 BODY: Bayesian spam probability is 0 to 1%
[score: 0.0000]
X-Spam-Key-2B-F6-5F: 0.1 HTML_70_80 BODY: Message is 70% to 80% HTML
X-Spam-Key-2B-F6-5F: 0.1 HTML_MESSAGE BODY: HTML included in message
X-Spam-Reclassify-2B-F6-5F
X-Virus-Checked-2B-F6-5F: 0 Anti-virus engine 4.02.0, released 06 February 2006, 119637 virus identities.
Return-Path: ***@***.org
X-OriginalArrivalTime: 01 Jun 2006 08:44:10.0576 (UTC) FILETIME=[8D4A8D00:01C6855
------_=_NextPart_001_01C6
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding:
------_=_NextPart_001_01C6
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding:
------_=_NextPart_001_01C6
Retrieving an IP address that is prefixed with "192.168." is probably not going to be much use anyway (unless you are inside the sender's network).
ASKER
Sorry I removed the 'Real' IP addresses and replaced them with 192's to protect the senders details etc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Works a treat!!
Thanks for all your help!
Thanks for all your help!