Script to search from txt file lines that contain ERROR or WARN and if found them send it to mail



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
.



Relevant Pages

  • Re: Script to search from txt file lines that contain ERROR or WARN and if found them send it to mai
    ... If the script found any lines that contain those it will send those ... Where should I put Line strLine = Ucase? ... Set cdoConfig = CreateObject ... Set cdoMessage = CreateObject ...
    (microsoft.public.scripting.vbscript)
  • Re: Newbie seeks simple help
    ... This is the script that I use when I want to send an email. ... Sends SMTP mail using local SMTP server and pickup folder. ... Set cdoMessage = CreateObject ... > I learned a lot about the Outlook object model in Outlook newsgroups. ...
    (microsoft.public.scripting.wsh)
  • Re: 800A0400 Error Message
    ... In ASP you need that to tell IIS to break into script, ... > Source: Microsoft VBScript comiplation error ... > Set cdoMessage = Nothing ...
    (microsoft.public.scripting.vbscript)
  • Re: Use SMTP Service Running On Another Server
    ... As Michael wrote in the post (and cannot be seen in the Google ... use in your script from that listing, ... Const cdoSendUsingMethod = _ ... Set cdoMessage = CreateObject ...
    (microsoft.public.scripting.vbscript)
  • Re: CDONTS to CDO script with saved fields
    ... you need to include the cdo type library - copy and paste this above your ... ' your script ... > This is the CDO script I've tried that gives me the error message also ... > Set cdoMessage = Nothing ...
    (microsoft.public.frontpage.client)

Loading