Avatar of purpleoak
purpleoakFlag for United Kingdom of Great Britain and Northern Ireland

asked on 

VBS Script for email header IP

I need to right a VBS script that can have a text document passed to it, then it reads through the text document and looks for the last occurrence of Received From: ([127.0.0.1]) and adds a new line to the text file saying Originating-IP: 127.0.0.1

The command to run the VBS would need to be "extractIP.vbs 123454343454.txt" ie the text file to check through is specified. An example text from the file is the following.

Received: from mailfilteruk.com ([192.133.7.42]) by mailfilteruk.com with MailEnable ESMTP; Thu, 19 May 2011 16:11:08 +0100
Received: from modernwebsites.myvirtuozzo.com ([192.133.7.32]) by mailfilteruk.com with MailEnable ESMTP; Thu, 19 May 2011 16:09:58 +0100
Received: from modernwebsites.co.uk ([64.151.225.132] helo=modernwebsites.myvirtuozzo.com)
      by MFS032F.mailfilteruk.com with ESMTP (2.0.1); 19 May 2011 16:06:05 +0100
Received: from host86-163-57-254.range86-163.btcentralplus.com ([86.163.57.254] helo=damien-intel.home)
      by modernwebsites.myvirtuozzo.com with esmtpsa (TLSv1:AES256-SHA:256)
X-Originating-IP:86.163.57.254


As you can see there are several received from IP address, the one i need however is the last one in bold. To further complicate the issue the IP will be different each time so it will need to look for the last instance of received from: ([

It will then add the following string. X-Originating-IP:86.163.57.254 to the line after the received from line.

So it would then look like the following.

Received: from mailfilteruk.com ([192.133.7.42]) by mailfilteruk.com with MailEnable ESMTP; Thu, 19 May 2011 16:11:08 +0100
Received: from modernwebsites.myvirtuozzo.com ([192.133.7.32]) by mailfilteruk.com with MailEnable ESMTP; Thu, 19 May 2011 16:09:58 +0100
Received: from modernwebsites.co.uk ([64.151.225.132] helo=modernwebsites.myvirtuozzo.com)
      by MFS032F.mailfilteruk.com with ESMTP (2.0.1); 19 May 2011 16:06:05 +0100
Received: from host86-163-57-254.range86-163.btcentralplus.com ([86.163.57.254] helo=damien-intel.home)
      by modernwebsites.myvirtuozzo.com with esmtpsa (TLSv1:AES256-SHA:256)
X-Originating-IP:86.163.57.254

I hope that all makes sense.
VB Script

Avatar of undefined
Last Comment
purpleoak
Avatar of purpleoak
purpleoak
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Any Body got anything I can use as a starting point on this?
ASKER CERTIFIED SOLUTION
Avatar of Darren Collins
Darren Collins
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of purpleoak
purpleoak
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Perfect exactly what I needed. Thanks so much for your help. I have another open question regarding the same problem. If you answer that you can have the points for that asell.

You have no idea how much this helps us.
VB Script
VB Script

VBScript (Visual Basic Scripting Edition) is an interpreted scripting language developed by Microsoft that is modeled on Visual Basic, but with some important differences. VBScript is commonly used for automating administrative and other tasks in Windows operating systems (by means of the Windows Script Host) and for server-side scripting in ASP web applications. It is also used for client-side scripting in Internet Explorer, specifically in intranet web applications.

39K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo