Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
It's not very straight-forward, and would depend on the specific 'details' you wish to gather, and for which event(s). Perhaps edit your question and provide those specifics? There's good info/tutorial on it here on Technet. –  techie007 Feb 12 '12 at 23:22
    
@techie007 thanks for reply. I've updated question –  kurochenko Feb 12 '12 at 23:41
    
So all you want is an email when someone logs on? Do you need to know who logged on or anything like that? –  techie007 Feb 12 '12 at 23:44
    
Is there a specific event log entry you are attemping to base this off of? I'd use a different approach, create a Task that is triggered by login that runs a script to get current user and then email it. Such a script is pretty straight forward in PS. –  edusysadmin Feb 12 '12 at 23:46
    
@techie007 yes, email with event message which can be seen in Event Viewer –  kurochenko Feb 12 '12 at 23:46
add comment

3 Answers

up vote 4 down vote accepted

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") : enter image description here

share|improve this answer
    
And how do i get event message to emails body? –  kurochenko Feb 13 '12 at 8:49
    
(First, in addition to manually creating the task above, you can more easily setup the task thru the event log. Find Event 4624 and pick "Attach taqsk to this Event..".) –  jdh Feb 13 '12 at 16:41
    
Then the task needs to be exported (to an XML file), edited to include event fields and then imported back into the task scheduler as a new event. Here's an example of someone doing something similar - blogs.technet.com/b/otto/archive/2007/11/09/… –  jdh Feb 13 '12 at 16:46
add comment

This seems simpler if you want the event text too

http://blogs.technet.com/b/jhoward/archive/2010/06/16/getting-event-log-contents-by-email-on-an-event-log-trigger.aspx

share|improve this answer
1  
Can you please share actual solution instead of just posting a link? –  Martin Prikryl Jan 15 at 15:05
add comment

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/

share|improve this answer
    
Need more than a link. Expand to show the solution other wise this is a trite answer and the link may eventualy break. –  Carl B Mar 21 at 7:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.