【发布时间】:2017-04-03 13:24:45
【问题描述】:
尝试获取应用脚本来检查消息进入的星期几,并在某些日子(例如周六和周日)收到消息时自动回复消息。我希望对消息中的文本进行一些格式化,以包括某些文本的颜色、回车符等。我有以下代码处理两个错误。 1.回复文字没有格式化。 2. 如果其他人打开了外出消息,我最终会收到一个循环的电子邮件。是否可以通过向自动回复回复的消息线程添加标签来解决此问题?
提前感谢您的帮助。
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 = "**Auto Reply** Thank you for your email! I am out of the office for the weekend spending time with my family. I will be back in the office Monday at 8:00 am. My usual office hours are Monday- Friday 8:00 am-4:00 pm EST. I monitor email periodically over weekends for emergencies. I look forward to assisting you. 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);
}
}
}
【问题讨论】: