我已根据上述内容创建了以下脚本,以便在我们的Gmail商务版应用中,在周一至周五上午9点之前和下午5点之后回复电子邮件。
无论出于什么原因,我都看不到它没有成功。有小费吗。它表示它执行,运行时间为0秒,所有用于Gmail的API都已启用。
我不禁认为它与Gmail商业应用有关,因为我在私有Gmail上对其进行了测试,但效果很好。
工作日上午9点之前和下午5点之后的第一个脚本是
function AutoReply()
{
var interval = 5;
var date = new Date();
var day = date.getDay();
var hour = date.getHours(); if ([1,2,3,4,5].indexOf(day) > -1 || (day ==
[1,2,3,4,5] && hour < 9) || (day == [1,2,3,4,5] && 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++)
{
if (threads[i].isUnread()){
threads[i].reply("Thank you for reaching out to us. Our Customer Support
Team is available Monday to Friday between 9am and 5pm. We are looking m
forward to helping you with your enquiry during business hours.In the
meantime, please check our Frequently Asked Questions page, Delivery page or
Returns page for more information which can be found on our website at
www.xxxxxxxxxxxxxxx.com.au and follow the links at the bottom of the
page.");
threads[i].markRead();
threads[i].markImportant();
}
}
}
}
周末版本适用于周六和周日
function AutoReply() {
var interval = 5;
var date = new Date();
var day = date.getDay();
var hour = date.getHours(); if ([6,0].indexOf(day) > -1 || (day == [6,0] &&
hour < 24) || (day == [6,0] && hour >= 0))
{
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++)
{
if (threads[i].isUnread())
{ threads[i].reply("Thank
you for reaching out to us.Our Customer Support Team is available Monday to
Friday between 9am and 5pm. We are looking forward to helping you with your
enquiry during business hours.In the meantime, please check our Frequently
Asked Questions page, Delivery page or Returns page for more information
which can be found on our website at www.xxxxxxxxxxxxxxx.com.au and follow
the links at the bottom of the page.");
threads[i].markRead();
threads[i].markImportant();
}
}
}
}
提前感谢任何建议
在我创建的这个烂摊子中是否有错误?
答案 0 :(得分:1)
这可以通过Gmail本身的设置来完成。您将有一个预定义的选项,您可以在其中设置自动回复,该回复将在您设置的时间内回复。