Script to search from txt file lines that contain ERROR or WARN and if found them send it to mail
- From: tomi.harman@xxxxxxxxx
- Date: Wed, 13 Feb 2008 10:00:08 -0800 (PST)
Hi,
I´m really neube on this and please help me with this.
So I need script that search from c:\temp1\testi1.txt file lines that
have word ERROR or WARN.
If the script found any lines that contain those it will send those
lines via email.
I know that this is very easy for you, but I´m having big problems
with this,
Here is my script what I´m working (And yes I know that it´s not
good) :)
Could you please help me with this.
------------------------------------------------------------------------------------------------------------------
set fso=CreateObject("Scripting.FileSystemObject")
set fRead =fso.OpenTextFile("c:\temp1\testi1.txt",1)
Do While fRead.AtEndOfStream <> True
strLine=fRead.ReadLine
if instr(strLine,"ERROR") or instr(strLine,"WARN") then
strMail=strMail & strLine & vbcrlf
end if
loop
set fRead=nothing
set fso=nothing
Function sendmail
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "81.228.8.17"
.update
End With
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.From = "from@xxxxxx"
.To = "to@me"
.Subject = "Sample CDO Message"
.TextBody = "This is a test for CDO.message"
.Send
End with
Set cdoMessage = Nothing
Set cdoConfig = Nothing
end function
.
- Follow-Ups:
- Prev by Date: Re: True or False comparison
- Next by Date: Re: Import and Insert data from email
- Previous by thread: Import and Insert data from email
- Next by thread: Re: Script to search from txt file lines that contain ERROR or WARN and if found them send it to mail
- Index(es):
Relevant Pages
|
Loading