title: Sending Email from R - when Scheduled script Fails in Windows
body: <p>I Have a Rscript file (Main_Script.R) which runs as a sheduled job in windows Task Scheduler every 30 Mins.Inside the <code>Main_Script.R</code> - i have around 13 scripts that runs every 30 mins.</p>
  
  <p>I wanted to send Email from R - whenever an iteration is failed or haulted.
  I am using sendMailR package - and i have seen an post in SO <code>how to send email with attachment from R in windows</code> - on how to send emqil from R Windows.</p>
  
  <p>But i am not sure about - how to send an <code>email automatically with the error message</code> - when the scheduled task iteration is failed or haulted.</p>
  
  <p>My <code>Main_Script.R</code> - has <code>source</code> of all 13 codes. </p>
  
  <pre><code>source(paste(rootAddress,"Scripts/Part1.R",sep =''))
  source(paste(rootAddress,"Scripts/Part2.R",sep =''))
  :
  :
  :
  :
  source(paste(rootAddress,"Scripts/Part13.R",sep =''))
  </code></pre>
  
  <p>My Sheduled task looks like below with log file</p>
  
  <pre><code>"D:\xxx\R-3.0.2\bin\x64\Rscript.exe" "D:\xx\Batch_Processing\Batch_Processing_Run\Scripts\Main_Test.R" &gt;&gt; "D:\XXX\Batch_Processing\Batch_Processing_Run\error.txt" 2&gt;&amp;1
  </code></pre>
  
  <p>Update: </p>
  
  <p>When the script encounters error - it should trigger email - with the erorr meassge and the script name or number -to denote which of the 13 scripts failed and send to a mail ID.</p>