0

I am trying to add an Auto reply to emails received during non-business hours. The vacation responder does not allow for this. Business Hours are Monday-Thursday 8:30 am-4:00 pm and Friday 8:30 am-12:00 pm MTN TIME. Below is the script I am using, is there a way I can add the MTN Time zone to this script so it sends during the correct hours for the correct time zone?

function autoReply() {
  var interval = 5;    //  if the script runs every 5 minutes; change otherwise
  var date = new Date();
  var day = date.getDay();
  var hour = date.getHours();
  if ([5,6,0].indexOf(day) > -1 || (day == 1 && hour < 8) || (day == 4 && hour >= 17)) {
    var timeFrom = Math.floor(date.valueOf()/1000) - 60 * interval;
    var threads = GmailApp.search('is:inbox after:' + timeFrom);
    for (var i = 0; i < threads.length; i++) {
      threads[i].reply("I am out of office. Your email will not seen until Monday morning.");
    }
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.