У меня был скрипт, который работал до месяца назад .. Никаких ошибок просто не было.GmailApp.sendEmail перестает работать
Я так пытался переписать сценарий с некоторой помощью от других, но до сих пор ничего ...
Сценарий прилагается к электронной таблице Google Form Response. Когда форма отправлена, она должна отправить 2 письма. Один для подателя и один для получателя.
здесь, где я нахожусь. Еще никаких ошибок. По крайней мере, я ничего не знаю.
function getResponseURL(timestamp) {
var id = SpreadsheetApp.getActive().getFormUrl().match(/[\_\-\w]{25,}/);
var form = FormApp.openById(id);
var resp = form.getResponses(new Date(timestamp.getTime() - 1000*5));
if (resp.length) return resp[0].getEditResponseUrl(); else return "";
}
function SendGoogleForm(e) {
var val = {
/*
Enter column header for recipient address
For an example
'subject': 'Email'
*/
'recipient': 'Email',
/*
Enter your email alias
*/
'alias': '[email protected]',
/*
Receiver's email for the notifications:
*/
'to': '[email protected]',
/*
ReplyTo email for the receiver's notifications:
*/
'replyto' : '[email protected]',
/*
1. the subject includes a row number and the person's name automatically - just want to fill in the text afterwards
Change the 'subject' value below.
For an example
'subject': 'test'
OR
'subject': 'the text afterwards'
*/
'subject': 'Quote Request',
'subject2': 'Quote Request',
/*
2. the body of course includes the form fields that were filled in, I just want to add text prior to that.
Change the 'text' value below.
For an example
'text': 'test'
OR
'text': 'add text prior to that'
*/
'text': 'The following quote request has been submitted.'
}
var recipient = "";
var s = SpreadsheetApp.getActiveSheet();
var headers = s.getRange(1,1,1,s.getLastColumn()).getValues()[0];
var subject = "[#" + s.getLastRow() + "] " + e.namedValues["Name"].toString() + " " + val.subject;
var body, message = [['','']];
for(var i in headers) {
var col = headers[i];
if (e.namedValues[col] && (e.namedValues[col].toString() !== "") && (col !== "Timestamp") && col !== "What is the color of oranges?") {
message.push([col, e.namedValues[col].toString()]);
if (col === val.recipient) {
recipient = e.namedValues[col].toString();
}
}
}
var textBody = "", htmlBody = "";
for (var i=0; i<message.length; i++) {
htmlBody += "<tr><td><strong>" + message[i][0] + '</strong></td><td>'+ message[i][1] + "</td></tr>";
textBody += message[i][0] + " :: " + message[i][1] + "\n\n";
}
htmlBody = val.text + "<br /><br /><table border='0' cellspacing='0' cellpadding='2'>" + htmlBody + "</table>";
textBody = val.text + "\n\n" + textBody;
var responseURL = getResponseURL(new Date(e.namedValues["Timestamp"].toString()));
/*
3. the body also includes a line with a link to edit the response at the end.
It's below
*/
if (responseURL !== "") {
htmlBody = htmlBody + "<br><br>" + "You can edit the response by <a href='" + responseURL + "'>clicking here</a>.";
textBody = textBody + "\n\n" + "Click the link below to edit the response:\n" + responseURL;
}
GmailApp.sendEmail (val.to, subject, textBody, {
htmlBody: htmlBody, replyTo: recipient, from: val.alias });
GmailApp.sendEmail (recipient, val.subject2, textBody, {
htmlBody: htmlBody, replyTo: val.replyto, from: val.alias });
}
function Authorize() {
Browser.msgBox("Script authorized.");
}
function InitializeTriggers() {
Reset(true);
ScriptApp.newTrigger("SendGoogleForm")
.forSpreadsheet(SpreadsheetApp.getActiveSpreadsheet())
.onFormSubmit()
.create();
}
Когда сценарий внезапно остановился, никаких уведомлений не было отправлено. Это было то, что я имел в виду, не произнося никаких ошибок. После проверки этих переписывает эти ошибки, присланные мне прошлой ночью Резюме: Сообщение об ошибке \t Count Недопустимый аргумент: [email protected] (строка 133, файл «Код») \t ReferenceError: «getResponseURL» является не определен. (Строка 113, файл "Код") Подробности: SendGoogleForm \t Недопустимый аргумент: [email protected] (строка 133, файл "Код") \t formSubmit SendGoogleForm \t ReferenceError: "getResponseURL" не определен. (строка 113, файл «Код») \t formSubmit –