我基于上述内容创建了以下脚本,以便在周一至周五上午 9 点之前和下午 5 点之后在我们的 Gmail 企业版应用程序中回复电子邮件。
无论出于何种原因,我看不到它没有成功。任何提示。它说它执行,运行时间为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();
}
}
}
}
提前感谢您的任何建议
在我创建的混乱中,我是否缺少错误?
这可以通过Gmail本身的设置来完成。您将有一个预定义的选项,您可以在其中设置自动响应,该响应将在您设置的时间内回复。