Skip to content

Codepolice

  • ⤫

Send E-Mail When a task in Task Scheduler Fails

Posted by Judy Alvarez Posted on February 28, 2022March 1, 2022
0

You would guess that this would be a really easy task but it turns out this was pretty complicated. Basically, you need to create a scheduled task that gets triggered by an event and do some editing of that task in a notepad. I will just post my exported task here. Feel free to use it / modify it as you want.
<?xml version=”1.0″ encoding=”UTF-16″?>
<Task version=”1.2″ xmlns=”http://schemas.microsoft.com/windows/2004/02/mit/task”>
<RegistrationInfo>
<Date>2012-09-07T09:36:00.5466938</Date>
<Author>Administrator</Author>
</RegistrationInfo>
<Triggers>
<EventTrigger>
<Enabled>true</Enabled>
<Subscription>&lt;QueryList&gt;&lt;Query Id=”0″ Path=”Microsoft-Windows-TaskScheduler/Operational”&gt;&lt;Select Path=”Microsoft-Windows-TaskScheduler/Operational”&gt;*[System[(EventID=201)]] and *[EventData[(Data[@Name=”ResultCode”]!=0)]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
<ValueQueries>
<Value name=”custom”>Event/EventData/Data[@Name=’TaskName’]</Value>
<Value name=”eventChannel”>Event/System/Channel</Value>
<Value name=”eventRecordID”>Event/System/EventRecordID</Value>
<Value name=”eventSeverity”>Event/System/Level</Value>
</ValueQueries>
</EventTrigger>
</Triggers>
<Principals>
<Principal id=”Author”>
<UserId>Administrator</UserId>
<LogonType>Password</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>P3D</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context=”Author”>
<SendEmail>
<Server>localhost</Server>
<Subject>Event $(eventRecordID) – $(custom) – $(eventChannel)</Subject>
<To>[email protected]</To>
<From>[email protected]</From>
<Body>Yo!</Body>
<HeaderFields />
<Attachments />
</SendEmail>
</Actions>
</Task>
Just save it as an XML file and import it into the Task Scheduler.

Categories: JavascriptTagged: asp dot net interview questions, asp dot net tutorial, asp net core 3, asp net core health check, asp net core vs php, asp net developer job, asp net development companies, asp net ecommerce website, asp net events, asp net for beginners, asp net interview questions and answers for 5 years experience, asp net microsoft, asp net middleware, asp net mvc là gì, asp net mvc projects, asp net page life cycle events, asp net pdf generator, asp net programming language, asp net service, asp net web app, c# asp net tutorial, client side validation in asp net, data controls in asp net, entry point of asp net core application, hire asp net developer india, html server controls in asp net, html to pdf asp net, net asp, regular expression validator in asp net, treeview control in asp net

Post navigation

Previous Previous post: Run Dropbox As a Windows Service on Windows Server 
Next Next post: Using log4net to Send Mail With SmtpAppender In a Console Application

Related Posts

  • What’s next for JavaScript frameworks in 2026

    #​770 — January 27, 2026 Read on the Web JavaScript Weekly Introducing LibPDF: PDF Parsing and Generation from TypeScript — LibPDF bills itself as ‘the PDF library TypeScript deserves’ and supports parsing, modifying, signing and generating PDFs with a modern API in Node, Bun, and the browser. GitHub repo. Documenso JavaScript Frameworks – Heading into 2026

    Posted by Posted on January 27, 2026
    0
  • require(esm) now stable in Node 25

    #​608 — January 22, 2026 Read on the Web Node.js 25.4.0 (Current) Released — Another gradual step forward for Node with require(esm) now marked as stable, as well as the module compile cache, along with a variety of other minor tweaks. Joyee Cheung of the Node team has written a thread on Bluesky going deeper

    Posted by Posted on January 22, 2026
    0
  • A big week for jQuery

    #​769 — January 20, 2026 Read on the Web JavaScript Weekly jQuery 4.0 Released — 20 years on from its original release, the ever-popular (in terms of actual usage) library reaches 4.0 with a migration to ES modules (compatible with modern build tools) along with dropping support for IE 10 and older. With jQuery being

    Posted by Posted on January 20, 2026
    0
  • A new guide to configuring Node packages

    #​607 — January 15, 2026 Read on the Web ⚠️ The Node.js January 13, 2026 Security Releases — Originally expected in December, these releases (of Node.js 25.3.0, 24.13.0, 22.22.0, and 20.20.0) finally landed this week, largely due to their complexity and the scope of the vulnerabilities they tackle. More on that in the next item! The Node.js

    Posted by Posted on January 15, 2026
    0
  • Can we ever fix the web dependency mess?

    #​768 — January 13, 2026 Read on the Web JavaScript Weekly Web Dependencies are Broken; Can We Fix Them? — Lea, who has worked at the heart of Web Standards for years, delivers a compelling (and educational) call to action about a problem every JavaScript developer has encountered: why is managing dependencies and introducing them

    Posted by Posted on January 13, 2026
    0
  • The story of how require(esm) became stable

    #​606 — January 8, 2026 Read on the Web 🎉 Happy New Year! Also, a quick reminder that Node Weekly is now sent every Thursday as part of a reshuffle for many of our newsletters. __Your editor, Peter Cooper npm to Implement ‘Staged Publishing’ After Turbulent Shift Off Classic Tokens — 2025 was a tricky year

    Posted by Posted on January 8, 2026
    0
Judy Alvarez

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Codepolice

  • Github
  • Atlassian
  • Flatlogic
  • Xero
  • Jetbrains
  • Figma
  • What’s next for JavaScript frameworks in 2026
  • require(esm) now stable in Node 25
  • A big week for jQuery
  • A new guide to configuring Node packages
  • Can we ever fix the web dependency mess?
https://flatlogic.com/generator
COPYRIGHT © 2026 - Codepolice