![](/img/trans.png)
[英]How can I create a function which will take a date and return schedules based on time condition
[英]How can I create a script which triggers an email based on a date?
再次,我对谷歌脚本不是很熟练,但是我在这里得到了很多支持,所以任何指导都将不胜感激。
我希望能够提醒收件人一个流程应在某个日期之前进行更新。 理想情况下,希望在流程到期前 1 个月发送提醒,然后在流程到期前 1 周再次发送提醒。
我希望能够发送一个通用的 email,其中唯一的变量是收件人姓名、email 地址、截止日期和流程名称。
关于我如何做到这一点的任何想法或任何可行的教程。 我已将链接附加到应触发电子邮件的 google 工作表
https://docs.google.com/spreadsheets/d/1Qw8WefbVkS-AQXi1CcZ0z2CL-P0oNSZYqeT40oVF6go/edit?usp=sharing
我让你自定义文本...
function reminder() {
var sh = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet()
var data = sh.getDataRange().getValues()
var d = new Date().getTime();
for (var i=1;i<data.length;i++){
if (data[i][4]<=new Date(d+7*24*60*60*1000) && data[i][4]>=new Date(d+5*24*60*60*1000) && data[i][6]!=''){
MailApp.sendEmail({to:data[i][3],
subject: 'reminder ... week',
htmlBody: 'Hello '+data[i][1]+' The process for '+data[i][0]+' is due to review on '+data[i][4]+' Please review the content and contact the process team before its due date if amendments are required'
})
sh.getRange(i+1,7).setValue('sent')
}
else if (data[i][4]<=new Date(d+30*24*60*60*1000) && data[i][4]>=new Date(d+28*24*60*60*1000) && data[i][5]!=''){
MailApp.sendEmail({to:data[i][3],
subject: 'reminer ... month',
htmlBody: 'Hello '+data[i][1]+' The process for '+data[i][0]+' is due to review on '+data[i][4]+' Please review the content and contact the process team before its due date if amendments are required'
})
sh.getRange(i+1,6).setValue('sent')
}
}
}
然后每天触发一次
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.