我想使用Google脚本为表单的非响应者生成自动提醒电子邮件。
我的第一个问题是:是否可以使用谷歌脚本来抓取等待响应"电子邮件地址列表?
如果可以的话,请参阅下面我注明的代码"这是我需要帮助的地方"
提前致谢。
FORM_OPEN_DATE = "2017-05-18 08:00";
FORM_CLOSE_DATE = "2017-05-19 15:00";
EMAIL_REMINDER = "2017-05-18 17:00";
/* Initialize the form, setup time based triggers */
function Initialize() {
deleteTriggers_();
if ((FORM_OPEN_DATE !== "") &&
((new Date()).getTime() < parseDate_(FORM_OPEN_DATE).getTime())) {
closeForm();
ScriptApp.newTrigger("openForm")
.timeBased()
.at(parseDate_(FORM_OPEN_DATE))
.create();
}
if (FORM_CLOSE_DATE !== "") {
ScriptApp.newTrigger("closeForm")
.timeBased()
.at(parseDate_(FORM_CLOSE_DATE))
.create();
}
}
/* ==============================*/
/* THIS IS WHERE I NEED HELP
function autoGenEmail {
var currentTime = d.toLocalTimeString;
//Should both currentTime and EMAIL_REMINDER be strings? How can I make
//the < comparison between the two values?
if (currentTime < EMAIL_REMINDER) {
// Get email addresses of nonresponders
// Generate and send an email to nonresponders
}
*/
/* ==============================*/
/* Delete all existing Script Triggers */
function deleteTriggers_() {
var triggers = ScriptApp.getProjectTriggers();
for (var i in triggers) {
ScriptApp.deleteTrigger(triggers[i]);
}
}
/* Send a mail to the form owner when the form status changes */
function informUser_(subject) {
var formURL = FormApp.getActiveForm().getPublishedUrl();
MailApp.sendEmail(Session.getActiveUser().getEmail(), subject, formURL);
}
/* Allow Google Form to Accept Responses */
function openForm() {
var form = FormApp.getActiveForm();
form.setAcceptingResponses(true);
informUser_("Your Google Form is now accepting responses");
}
/* Close the Google Form, Stop Accepting Reponses */
function closeForm() {
var form = FormApp.getActiveForm();
form.setAcceptingResponses(false);
deleteTriggers_();
informUser_("Your Google Form is no longer accepting responses");
}
/* Parse the Date for creating Time-Based Triggers */
function parseDate_(d) {
return new Date(d.substr(0,4), d.substr(5,2)-1,
d.substr(8,2), d.substr(11,2), d.substr(14,2));
}