title: How can I turn on Gmail's vacation autoresponder with a script?
body: <p>I would like to be able to turn Gmail's vacation responder on automatically everyday at 5pm and then have it turned off at 8am every day. This is so we can send an email to anyone who emails us after hours to let them know they should call the on-call technician. </p>
  
  <p>I already made a script that kind of works but isn't the best. I'm hoping that there is a way to simply turn it on or off with one line of code. Here is what I have so far.</p>
  
  <pre><code>    function myFunction() {
  
   var date = new Date();
  
    //Sun=0 Mon=1 Tue=2 ... Sat=6
  if(date.getDay() == 1 || 2 || 3 || 4 || 5)
      {
  if(date.getHours() &gt; 8)//If it's before 8:00am
        {
  
  
         var firstThread = GmailApp.getInboxThreads(0,1)[0];
          var message = firstThread.getMessages()[0];
          message.reply("Thank you for contacting xxxxxxxxx technical support.             
          If this is an emergency please call the on-call technician.");
           GmailApp.moveMessageToTrash(message);
  
        }
  
  if(date.getHours() &gt; 16)//If it's after 5:00pm
        {
         var firstThread = GmailApp.getInboxThreads(0,1)[0];
        var message = firstThread.getMessages()[0];
        message.reply("Thank you for contacting xxxxxxx technical support. 
        If this is an emergency please call the on-call technician.");
        GmailApp.moveMessageToTrash(message);
       }
     }
  
  if(date.getDay() == 6 || 0)//Runs all day if on a Saturday or Sunday
      {
      var firstThread = GmailApp.getInboxThreads(0,1)[0];
      var message = firstThread.getMessages()[0];
      message.reply("Thank you for contacting xxxxxxxx technical support. 
      If this is an emergency please call the on-call technician.");
      GmailApp.moveMessageToTrash(message);
  
   }
  }
  </code></pre>
  
  <p>Any help would be appreciated.</p>