Solved

script

Posted on 2016-10-26
2
33 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 24

Accepted Solution

by:
NVIT earned 500 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 24

Expert Comment

by:NVIT
ID: 41886048
Question answered.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 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