0
我試圖編寫一個腳本,每次填寫某個Google表單時都會發送一封電子郵件。除了我無法弄清楚如何放置包含標題的數組的內容以及問題內容&他們對電子郵件正文中最近一組答案的回答!我不能把代碼放到「.sendEmail」功能是這樣的:Google Apps腳本 - 如何發送包含數組內容的電子郵件?
MailApp.sendEmail("[email protected]",
"The form has been updated",
for (var j = 0 ; j < array.length ; j++) {
array[j];
});
我不能想出辦法如何包含內容!以下是完整的腳本:
function onEdit(e) {
//get form by ID
var form = FormApp.openById('ID OF YOUR FORM GOES HERE');
//Get form Responses
var formResponses = form.getResponses();
var array = [];
var formResponse = formResponses[formResponses.length-1];
var itemResponses = formResponse.getItemResponses();
for (var j = 0; j< itemResponses.length; j++){
var itemResponse = itemResponses[j];
array.push(itemResponse.getItem().getTitle() + ": " + itemResponse.getResponse());
}
MailApp.sendEmail("[email protected]",
"The form has been updated",
for (var j = 0 ; j < array.length ; j++) {
array[j];
});
}