【发布时间】:2016-12-21 15:55:29
【问题描述】:
早上好,
我希望在正常办公时间以外的任何时候(美国东部标准时间 M-F 8a-4p EST)向我发送电子邮件时自动回复。
我已经知道如何在周六和周日执行此操作,但不知道如何将其与时间结合起来。下面是我现在使用的。
感谢您的帮助!
function autoReply() {
var interval = 5; // if the script runs every 5 minutes; change otherwise
var daysOff = [6,0]; // 1=Mo, 2=Tu, 3=We, 4=Th, 5=Fr, 6=Sa, 0=Su
var message = "Thank you for your email! I am currently away from the office for the weekend spending time with my family. I will be back in the office Monday morning at 8:00 am EST. My office hours are Monday - Friday 8:00 am - 4:00 pm EDT. I monitor email periodically over weekends for emergencies. I look forward to assisting you when I am back in the office. Thank you!"
var date = new Date();
var day = date.getDay();
if (daysOff.indexOf(day) > -1) {
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(message);
}
}
}
【问题讨论】: