Solved

script

Posted on 2016-10-26
2
25 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 23

Accepted Solution

by:
NVIT earned 500 total points (awarded by participants)
Comment Utility
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 23

Expert Comment

by:NVIT
Comment Utility
Question answered.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now