Outlook and Error Logs

  • How do I parse a flat file error log for 'severity 17882' and e-mail that to an individual?  Here's the code:

     

    objEmail.From = "roderick.benton@bellsouth.com"

    objEmail.To = "ddavis_3@imcingular.com"

    objEmail.Subject = "SQL ERROR"

    objEmail.Textbody = "AN ERROR HAS OCCURRED WITHIN THE ERRORLOG ON MSSQLCLUS01"

    objEmail.Configuration.Fields.Item _

        ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

            'response.bellsouth.com ?

    objEmail.Configuration.Fields.Item _

        ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _

              "response.bellsouth.com"

    Note: quotations marks are required.

    The Code (alert.vbs):

    ‘- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    ‘ remove the comment marker (‘) from On Error Resume Next

    ‘ when code runs without error

    ‘ On Error Resume Next

    ‘ declaring variables

    DIM strComputer,dtmDate,dtmDay,dtmMonth,dtmYear,strDate

    DIM intCounter,intCount,dtmWritDate,dtmWritDateY

    DIM dtmWritDateM,dtmWritDateD,strWritDate

    ‘ initializing some variables

    intCounter = 0

    strComputer = 90.152.80.117

    dtmDate = Now-1

    dtmDay = Right(("0" & Day(dtmDate)),2)

    dtmMonth = Right(("0" & Month(dtmDate)),2)

    dtmYear = Year(dtmDate)

    strDate = dtmYear & dtmMonth & dtmDay

    ‘ attaching to WMI provider on server

    Set objWMIService = GetObject("winmgmts:" _

        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

    ‘ the query

    Set colLoggedEvents = objWMIService.ExecQuery _

        ("Select * from Win32_NTLogEvent Where Logfile = 'Application' " & _

        "AND Type = 'Error' AND Severity = 18 AND EventCode = 17882")

    For Each objEvent in colLoggedEvents

     dtmWritDate = objEvent.TimeWritten

     dtmWritDateY = Left(dtmWritDate, 4)

     dtmWritDateM = Mid(dtmWritDate,5,2)

     dtmWritDateD = Mid(dtmWritDate,7,2)

     strWritDate = dtmWritDateY & dtmWritDateM & dtmWritDateD

     intCounter = intCounter + 1

     If strWritDate >= strDate Then

     intCount = intCounter

     End If

    Next

    If intCount > 1 Then

    ‘ e-mail section

     Set objEmail = CreateObject("CDO.Message")

     objEmail.From = "roderick.benton@bellsouth.com"

     objEmail.To = "ddavis_3@imcingular.com "

     objEmail.Subject = "SQL ERROR"

     objEmail.Textbody = "AN ERROR HAS OCCURRED WITHIN THE ERRORLOG ON MSSQLCLUS01"

     objEmail.Configuration.Fields.Item _

         ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

            'response.bellsouth.com ?

     objEmail.Configuration.Fields.Item _

         ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _

              "response.bellsouth.com"

      objEmail.Configuration.Fields.Item _

          ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

     objEmail.Configuration.Fields.Update

     objEmail.Send

    ‘ end of e-mail section

    End If

  • Don't post the same question in different fourms

    Thanks

    Sreejith

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply