Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

VBS Script for email header IP

Avatar of purpleoak
purpleoakFlag for United Kingdom of Great Britain and Northern Ireland asked on
VB Script
3 Comments1 Solution460 ViewsLast Modified:
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.
ASKER CERTIFIED SOLUTION
Avatar of Darren Collins
Darren CollinsFlag of United Kingdom of Great Britain and Northern Ireland imageTech Lead (Windows), Endpoint Device Management Services

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers