0
我正在使用以下小腳本爲星期五和星期六抵達的所有電子郵件創建外出郵件。這些腳本還將它們標記爲已讀,因爲當它們未讀時,它會陷入循環並不斷髮送外出消息。Gmail外出郵件腳本
問題是,當我週日回到我的辦公桌時,我無法分辨哪些新郵件到達,因爲它們已被標記爲「已讀」。我在週末看過很多電子郵件,所以我不能只讀回上週末的每封電子郵件,這會花很長時間。
我需要的是讓這些未讀的方法,而不是讓他們陷入循環。或者,我想爲該腳本觸及的每封電子郵件添加標籤「外出」,因此我可以在星期天對其進行審閱(假設我在此之前回覆電子郵件,則會刪除該標籤)。
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].indexOf(day) > -1 || (day == 0 && hour < 8) || (day == 4 && hour >= 19)) {
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("Hello! Our offices are closed for the weekend. I will be monitoring my emails sporadically and will do my best to answer any urgent inquiries. If this is not urgent, I will reply to your email on Sunday morning. Thank you for your patience. Now go have a great weekend!");
threads[i].markRead();
threads[i].markImportant();
}
}
}}