How do I send an email with event details when some event occurs in Windows 7, for example when any user logs on?
I've tried to use Event Viewer, but I haven't found out how to attach event details to the email's body.
How do I send an email with event details when some event occurs in Windows 7, for example when any user logs on?
I've tried to use Event Viewer, but I haven't found out how to attach event details to the email's body.
Use the task scheduler from the (Control Panel -> Administrator's Tools). It has the option to run a script, program or action, depending on some trigger (like someone logging on, running a program etc) Here's an example setup dialog (you are interested in the event "at log on") :
This seems simpler if you want the event text too
You need to export the job, edit XML file of the task and add value to ValueQueries. Import the job again and edit mail details. You can include Event Details and any information in the event.
Below article explains step by step on how to do the same: http://vijredblog.wordpress.com/2014/03/21/task-scheduler-event-log-trigger-include-event-data-in-mail/
ValueQueries
node inside . Add value
nodes inside it. For example:
<EventTrigger>
...
<ValueQueries>
<Value name="EventData">Event/EventData/Data</Value>
</ValueQueries>
...
</EventTrigger>
$(EventData)
to include the event detailsPlease note that not all Windows Server versions admit this XML schema, but I guess that any recent version (WS2012 onwards) will be fine. For example: WS2008 (non R2), which uses http://schemas.microsoft.com/windows/2004/02/mit/task schema, does not like it.