CalmSoul
asked on
getting logs based on date
I am looking for a VB6 script in which I will open event.log file and based on todays date will grab the logs.
Here is my event.log file
sometext, 6/26/2009, sometext
sometext, 6/27/2009, sometext
sometext, 6/27/2009, sometext
sometext, 6/27/2009, sometext
sometext, 6/27/2009, sometext
sometext, 6/27/2009, sometext
sometext, 6/29/2009, sometext
sometext, 6/29/2009, sometext
So in this example I only want to grab last two lines and email to myself
I know how the email part will work. just need help in passing last two lines to a variable.
Here is my event.log file
sometext, 6/26/2009, sometext
sometext, 6/27/2009, sometext
sometext, 6/27/2009, sometext
sometext, 6/27/2009, sometext
sometext, 6/27/2009, sometext
sometext, 6/27/2009, sometext
sometext, 6/29/2009, sometext
sometext, 6/29/2009, sometext
So in this example I only want to grab last two lines and email to myself
I know how the email part will work. just need help in passing last two lines to a variable.
ASKER
where the output is going?
I was hoping you'd be able to tell me :p. If you can provide an example of this email part you know how to get working then I can have a look at joining them up.
ASKER
here is the one which sends the email out
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("myTextFile.TXT")
If objFile.Size > 0 Then
Set objReadFile = objFSO.OpenTextFile("myTextFile.TXT", 1)
strFile= objReadFile.ReadAll
objReadFile.Close
Set objReadFile = Nothing
cPos = InstrRev(strFile, vbNewLine & "###")
If cPos>0 Then
cPos=cPos+2 'To not include the preceeding carriage return
Else
cPos=1
End If
strLastLines = Mid(strFile, cpos)
Else
End If
Set objFSO = Nothing
Set objFile = Nothing
If strLastLines <> "" Then
Set objEmail = CreateObject("CDO.Message")
Set cdoConfig = CreateObject("CDO.Configuration")
sch = "http://schemas.microsoft.com/cdo/configuration/"
cdoConfig.Fields.Item(sch & "sendusing") = 2
cdoConfig.Fields.Item(sch & "smtpserver") = "SMTP server"
cdoConfig.Fields.update
Set objEmail.Configuration = cdoConfig
objEmail.From = "sender address"
objEmail.To = "recipient"
objEmail.Subject = "auto send email thinggy"
objEmail.Textbody = strLastLines
objEmail.Send
Set objEmail = Nothing
Set cdoConfig = Nothing
End If
ASKER
Is it possible if I read date from another text file and then based on that date get logs? instead of todays date?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window