Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

script

Posted on 2016-10-26
2
Medium Priority
?
50 Views
Last Modified: 2016-11-14
Hello.. Script to read a text file and send email alert of particular content of that text file.

Example: Attached a .txt (carsim.txt) file which contains license expiry date "05-apr-2017"
Need script to read that particular line (line number 12 & 13) and send email through outlook.

Kindly help.
Carsim.txt
0
Comment
Question by:Karthick Rajendran
  • 2
2 Comments
 
LVL 25

Accepted Solution

by:
NVIT earned 2000 total points (awarded by participants)
ID: 41861433
Make doit.bat

find /i "carsim"<Carsim.txt>"c:\folder\output.txt"
cscript /nologo SendEmail.vbs

Open in new window


Make SendEmail.vbs.
Adjust Subject, From, To, TextBody, AddAttachment values to your needs.

Set MyEmail=CreateObject("CDO.Message")

MyEmail.Subject="Carsim license expiry date "
MyEmail.From="admin@domain.com"
MyEmail.To="admin@domain.com"
MyEmail.TextBody="See attachment"
MyEmail.AddAttachment "c:\folder\output.txt"

MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2

'SMTP Server
MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtpserver.domain.com"

'SMTP Port
MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25 

'SMTP Auth (For Windows Auth set this to 2)
MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=1

' If your server requires authentication, enable the Username and Password lines below:
'Username
'MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername")="admin@domain.com" 
'Password
'MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword")="password"

MyEmail.Configuration.Fields.Update
MyEmail.Send

set MyEmail=nothing

Open in new window


Run doit.bat
1
 
LVL 25

Expert Comment

by:NVIT
ID: 41886048
Question answered.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question