title: Google Apps Script Defined Time-frame for time-driven Triggers Not Working
body: <p>I am using the functions from the code that I saw here:
  <a href="http://mashe.hawksey.info/2012/09/google-app-script-scheduling-timed-triggers/" rel="nofollow">http://mashe.hawksey.info/2012/09/google-app-script-scheduling-timed-triggers/</a>
  with my added sub-function, as instructed. </p>
  
  <pre><code>function scheduledCollection2(){
    var schedule = [];
    // dates/times in mm/dd/yyyy hh:mm - timezone matches settings in File &gt; Project properties
    schedule.push({start:"10/25/2014 09:00", end:"12/25/2014 10:00"});
    checkCollect2(schedule);
  }
  
  function checkCollect2(schedule){
    var now = new Date();
    for (i in schedule){
      var start = new Date(schedule[i].start);
      var end = new Date(schedule[i].end);
      if (now &gt; start &amp;&amp; now &lt; end){
        function sendEmails() {
          var emailAddress = "abc@gmail.com";
          var message = "Hello, this is a test email.";
          var subject = "Sending Recurring Emails";
          MailApp.sendEmail(emailAddress, subject, message);
        }
      }
    }
  }
  </code></pre>
  
  <p>The sendEmails function alone works very well. However, when I add it to the rest of the code for some reason it stops working. My aim is to have it work with a time-driven trigger.</p>
  
  <p>Any advice on why it's not working, and how I can get it to work?</p>