How to create email notifications for Windows Events

Advertisement

Sometimes, you may want to know what is happening on your PC when you are not using it. Maybe you want to be informed when someone else is logging in on it, when a program gets started on it, or when other events happen that you want to know about.

While it is possible to browse the events of the system, it is not really that comfortable of an option due to the way they are presented and filtered.

An alternative to that is to configure the system to send out emails whenever something happens that you are interested in.

This guide looks at how this is done. Lets get started.

Event email notifications

windows event email tasks

You need a third-party program for the email sending part of the solution. We are using Blat, a free command line utility that can send emails using SMTP.

Note: Your antivirus or security software may block the program, or even the program's website, by default. You need to whitelist the website or application if that is the case if you want to use it. Why it is blocked? Because it can also be used to send out unsolicited emails (spam). A check of the most recent version of the tool revealed no hits on Virustotal.

Blat does not need to be installed, just extract it to a location on your system. Now that this is out of the way, it is time to configure the Task Scheduler.

  1. Tap on the Windows-key, type Schedule Tasks and select the result. If you use Windows 8 you do not need to tap on the Windows-key if you are already on the Start Screen.
  2. This opens the Windows Task Scheduler which you can use to configure automated tasks on the system.
  3. Select Action > Create Task from the menu.
  4. Type a name for the new task, e.g. Sign-In Notifications.
  5. Switch from "Run only when user is logged on" to "Run whether user is logged on or not".
  6. Switch to Triggers.
  7. Select New, this opens a new window.
  8. Select "On an event" under Begin the task.
  9. Here you can either type in an event ID or source, open the Log menu to select the event that you are interested in, for instance event 4624 or 4634 which log logon or logoff events.
  10. If you just want a notification on system start, change "on an event" to logon instead.
  11. Switch to Actions.
  12. Select New to open the new action window.

blat-email

The configuration of the action requires some explanation, as you need to use quite a few command line parameters. First thing to do is click on browse to select the blat.exe file on your local drive.

Add the following list of arguments under "add arguments" (all in one line):

-to "email recipient" -subject "enter subject" -body "enter body text" -server "enter SMTP server" -f "enter from email" |u "username for SMTP server" -pw "password for SMTP server"

Example:

-to email@example.com -subject Notification -body Logon -server smtp.mail.yahoo.com -f myemail@yahoo.com |u myemail@yahoo.com -pw mypassword

Once you are finished and click ok, you are asked to type the account password to complete the process.

I suggest you test the setup to see if it really works.

Security advice: Since you add the username and password of the SMTP server to the task, you may want to use a dummy account that you create solely for that purpose for that.

Closing Words

Creating email notifications for Windows events is not a difficult thing to do. Once you know what you need, it is a matter of looking up the email server information that you will be using for that.

It is important to note that you need to be careful in regards to events that you select as notification triggers. If you select an event that occurs often, you may send out too many emails too fast, which may result in a temporary or permanent account ban.

Please share this article

facebooktwittergoogle_plusredditlinkedinmail

Advertisement

Filed under:

Responses to How to create email notifications for Windows Events

  1. Sander January 3, 2014 at 1:53 pm #

    I always appreciate your posts Martin!

    Addition to this one: this can be done without 3rd party app or saving passwords (depending on the mailserver):

    http://www.lifeasasysadmin.com/send-an-email-when-an-event-is-logged-2/
    http://social.technet.microsoft.com/Forums/en-US/09b4e33a-8569-4660-8ba2-1f5b47c08583/powershell-scripting-to-send-emails-based-on-events-in-event-viewer-problem-is-sending-attachment

    And an example of your 'send email at login' here:
    http://poshcode.org/4633

  2. WieseNetOps January 3, 2014 at 2:13 pm #

    You don't necessarily need a third party program for sending the email. Powershell works very well for sending the email if you don't want to use Blat. I just set up some notifications like this for monitoring backup success/failure on Windows Server 2012 platforms last week.

  3. Jorge January 3, 2014 at 9:08 pm #

    Is setting the trigger "at log on" good enough for a process that requires being online? I ask this because sometimes it takes a while for my computer to go online after log on.

Leave a Reply