locked
Email Alert from an Event using Scheduler RRS feed

  • Question

  • I have created a task from the system log attached to Event ID: 1 Power-Management.

    This task is simply to send me an email to let me know that My server has been awoken from hibernation.

     

    However as it is built on server 2008 R2 spec - Microsoft assume you will have a local Exchange server to localhost the email to - but of course this is in deed a stand alone server on a home network and WHS 2011 does not support exchange.

     

    Is there anyway to set it up like the in built dashboard app for sending emails - like so http://usingwindowshomeserver.com/2011/02/25/windows-home-server-2011-email-notifications/

    Surely it can piggy back these settings somehow?

     

    Appreciate your help in advance.

     

    Thanks, Al.

    Tuesday, November 15, 2011 2:03 PM

Answers

  • Surely it can piggy back these settings somehow?

    Not really. Effectively, there is a simple email client built into the alert processing, which generates the email and sends it. As far as I can see, Microsoft hasn't provided any hooks to let external programs use that functionality.

    Instead, I would probably use something which would let me send an email from the command line. One such tool, freely available, is blat.exe, available from blat.net (and a host of other locations). Then I would wrap that in a command processor script.

    You might also be able to do something with Powershell; I'm really not sure. :)

    But why do you care that your server has waked from hibernation, given that it's designed to run all the time anyway? And have you considered that your scheduled task is likely to fire before your server has re-established it's network connection, which means you'll never see the email?


    I'm not on the WHS team, I just post a lot. :)
    • Marked as answer by alangmcc Tuesday, November 15, 2011 3:38 PM
    Tuesday, November 15, 2011 2:25 PM
  • Totally agree BullDawg.

     

    I got it working - setup 'hmailserver' on my whs 2011 and set it to relay smtp through one of my email accounts with BT Yahoo.

    Had to authenticate my address with BT before they allowed relaying from it - but this was an automated process following a verify link in an automated email.

    So setup a local account and set it to forward all email to an external personal account. :-)

     

    Then I used a wee vb script in an event trigger.

     

    Set objMessage = CreateObject("CDO.Message")
    objMessage.Subject = "XXXXXXXX Homeserver now online"
    objMessage.From = "xxxxxxxx@xxxxxx.homeserver.com"
    objMessage.To = "xxxxxx@xxxxxxxx.homeserver.com"
    objMessage.TextBody = "Hi Alan, your Windows Homeserver is now online after being woken with a WoL command."

    '==This section provides the configuration information for the remote SMTP server.
    '==Normally you will only change the server name or IP.
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

    'Name or IP of Remote SMTP Server
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"

    'Server port (typically 25)
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

    objMessage.Configuration.Fields.Update

    '==End remote SMTP server configuration section==

    objMessage.Send

    • Marked as answer by alangmcc Wednesday, November 16, 2011 11:45 AM
    Wednesday, November 16, 2011 11:45 AM

All replies

  • Surely it can piggy back these settings somehow?

    Not really. Effectively, there is a simple email client built into the alert processing, which generates the email and sends it. As far as I can see, Microsoft hasn't provided any hooks to let external programs use that functionality.

    Instead, I would probably use something which would let me send an email from the command line. One such tool, freely available, is blat.exe, available from blat.net (and a host of other locations). Then I would wrap that in a command processor script.

    You might also be able to do something with Powershell; I'm really not sure. :)

    But why do you care that your server has waked from hibernation, given that it's designed to run all the time anyway? And have you considered that your scheduled task is likely to fire before your server has re-established it's network connection, which means you'll never see the email?


    I'm not on the WHS team, I just post a lot. :)
    • Marked as answer by alangmcc Tuesday, November 15, 2011 3:38 PM
    Tuesday, November 15, 2011 2:25 PM
  • Thank you for your reply.

    Well I think a home server should not only be designed to run all day long.

    I say ONLY as there are very certainly different implementations of requirements from each owner depending on required infrastructure.

    And there seems to be alot of people with the same opinion granted there are several apps  - one add in to name is Lights out.

     

    I love my WHS 2011 - but use it around 5-7% of a given week - and this 5-7% is never the same 5-7% of any given time of that week so why should I pay for Electric charges @ 150 - 300 watts when in Hibernation it only consumes 3.4 watts? Makes sense to me.

    But I would like to know when it has been woken up - so as it is not woken by accident either by me or my wife/kids as it is easily done from iPhone app.

     

    Seems a little strange the left the functionality of email triggers when they are going to be pretty much useless in a very larger percentage of installs.

    I am going to try and get hMailServer running to facilitate this, I'll let you know how i get on. Thanks for your help, Alan.

     

     

     

     

    Tuesday, November 15, 2011 3:09 PM
  • I am going to try and get hMailServer running to facilitate this, I'll let you know how i get on. Thanks for your help, Alan.
    hMailServer runs fine on WHS2011 - unsupported of course.

    Phil P.S. If you find my comment helpful or if it answers your question, please mark it as such.
    Tuesday, November 15, 2011 3:18 PM
  • So here's how I view the question of hibernating my server. Hopefully it will offer some insight into why Microsoft may have chosen to design Windows Home Server to be an "always on" household server:

    If my server is in a power saving mode, it's not instantly available to respond to requests for data. Depending on hardware and boot/resume sequence, it may not be available for up to a couple of minutes after a request for data is initially submitted. That's too long for most people. Power isn't much of a consideration; my server, when on but idle, consumes about 45 watts of power, which is less than one average incandescent light bulb. "woken (sic) by accident" isn't a factor; if the server is in hibernation or sleep state and it's awakened, presumably it's to serve up some data, so I wouldn't really care why exactly it was awakened. It sounds like you're trying to control your users' use of or access to your server; if you want them to adopt and use the server, you're going about it the wrong way, as what you're doing is training them to not use it.

    As for leaving in the email action functionality, it just needs an open SMTP server. Those are basically non-existent these days unless you run one yourself (they're a great way for spammers to send out mass mailings semi-anonymously), but the functionality has been in Windows Task Scheduler (all versions, desktop as well as server) for years. So why not leave it in?


    I'm not on the WHS team, I just post a lot. :)
    Wednesday, November 16, 2011 2:39 AM
  • Bottom Line Up Front:  Power consumption is a factor to many outside the U.S.  Perhaps Microsoft needs to rethink the design of an "always on" home server.  (This was suggested/bugged during the v1 and WHS 2011 betas.  MS even responded to one that it would be considered in a future release.)
     
    "...consumes about 45 watts of power"
     
    1.  That's 1.1 Kwh per day or about 33 per month
    2.  That's 1.50 pounds of CO2 emissions per day or about 45 pounds per month
     
    Setting aside the environmental factor, in countries with progressive electrical rates, that would cost me $25 per month if I'm over the 500Kwh threshold for the month.  Billing goes to about 75¢ per Kwh at that point.    (First 300 cost about 5¢ per Kwh, 301-400 cost about 25¢ per Kwh, 401-500 are 50¢ per Kwh)  It makes flipping that light switch a habit when you leave the room.  Thankfully, we only have to run the A/C a few days out of the year.  Night time (10pm to 8am and weekends, holidays) is billed at the lower 5¢ per Kwh rate (not factored into above calculations) regardless of amount used.  That's when the washer, dryer, dishwasher all kick in; they are all programmed to run during the off peak cycle.
     
    BTW, my 9 drive system (all green low rpm drives that spin down after 10 minutes and Asus Zacate motherboard) uses about 18 watts at idle.  I have seen it peak as high as 49watts, but is generally around 30 when in normal supported activity.   My test box is almost identical but uses an Atom 510 motherboard and a different mix of 9 low power drives. 

    --
    ________________________________
     
    BullDawg
    In God We Trust
    ________________________________

    So here's how I view the question of hibernating my server. Hopefully it will offer some insight into why Microsoft may have chosen to design Windows Home Server to be an "always on" household server:

    If my server is in a power saving mode, it's not instantly available to respond to requests for data. Depending on hardware and boot/resume sequence, it may not be available for up to a couple of minutes after a request for data is initially submitted. That's too long for most people. Power isn't much of a consideration; my server, when on but idle, consumes about 45 watts of power, which is less than one average incandescent light bulb. "woken (sic) by accident" isn't a factor; if the server is in hibernation or sleep state and it's awakened, presumably it's to serve up some data, so I wouldn't really care why exactly it was awakened. It sounds like you're trying to control your users' use of or access to your server; if you want them to adopt and use the server, you're going about it the wrong way, as what you're doing is training them to not use it.

    As for leaving in the email action functionality, it just needs an open SMTP server. Those are basically non-existent these days unless you run one yourself (they're a great way for spammers to send out mass mailings semi-anonymously), but the functionality has been in Windows Task Scheduler (all versions, desktop as well as server) for years. So why not leave it in?


    I'm not on the WHS team, I just post a lot. :)

    BullDawg
    Wednesday, November 16, 2011 5:38 AM
  • Totally agree BullDawg.

     

    I got it working - setup 'hmailserver' on my whs 2011 and set it to relay smtp through one of my email accounts with BT Yahoo.

    Had to authenticate my address with BT before they allowed relaying from it - but this was an automated process following a verify link in an automated email.

    So setup a local account and set it to forward all email to an external personal account. :-)

     

    Then I used a wee vb script in an event trigger.

     

    Set objMessage = CreateObject("CDO.Message")
    objMessage.Subject = "XXXXXXXX Homeserver now online"
    objMessage.From = "xxxxxxxx@xxxxxx.homeserver.com"
    objMessage.To = "xxxxxx@xxxxxxxx.homeserver.com"
    objMessage.TextBody = "Hi Alan, your Windows Homeserver is now online after being woken with a WoL command."

    '==This section provides the configuration information for the remote SMTP server.
    '==Normally you will only change the server name or IP.
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

    'Name or IP of Remote SMTP Server
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"

    'Server port (typically 25)
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

    objMessage.Configuration.Fields.Update

    '==End remote SMTP server configuration section==

    objMessage.Send

    • Marked as answer by alangmcc Wednesday, November 16, 2011 11:45 AM
    Wednesday, November 16, 2011 11:45 AM