Hi,
The following script will listen to your local system and then send a mail when eventid 0 occurs.
Change strComputer = "." to strComputer = "MyHost" to listen to a remote machine.
Change TargetInstance.EventIdentifier = '0' to the number of the EventID you wish to trap.
Also you will need the IP address of an available SMTP mail server to use this script - enter this in the correct place in the script.
Cheers - S
***********************************************************
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Security)}!\\" & _
strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("Select * from __InstanceCreationEvent within 5 where TargetInstance isa 'Win32_NTLogEvent' and TargetInstance.EventIdentifier = '0'")
Do
Set objLatestEvent = colMonitoredEvents.NextEvent
Message = Message & chr(13) & "Record No.: " & objLatestEvent.TargetInstance.RecordNumber
Message = Message & chr(13) & "Event ID: " & objLatestEvent.TargetInstance.EventCode
Message = Message & chr(13) & "Time: " & objLatestEvent.TargetInstance.TimeWritten
Message = Message & chr(13) & "Source: " & objLatestEvent.TargetInstance.SourceName
Message = Message & chr(13) & "Category: " & objLatestEvent.TargetInstance.CategoryString
Message = Message & chr(13) & "Event Type: " & objLatestEvent.TargetInstance.Type
Message = Message & chr(13) & "Computer: " & objLatestEvent.TargetInstance.ComputerName
Message = Message & chr(13) & "User: " & objLatestEvent.TargetInstance.User
Message = Message & chr(13) & "Text: " & objLatestEvent.TargetInstance.Message
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "MyFromAddress@Somewhere.com"
objEmail.Replyto = "MyFromAddress@Somewhere.com"
objEmail.To = "sendtoyou@mail.com"
objEmail.Subject = "Event Log"
objEmail.Textbody = Message
objEmail.Configuration.Fields.Item ("
= 2
objEmail.Configuration.Fields.Item ("
= "<ip address of SMTP server>"
objEmail.Configuration.Fields.Item ("
= 25
objEmail.Configuration.Fields.Update
objEmail.Send
Loop