【发布时间】:2014-06-03 14:45:23
【问题描述】:
全部 -
我是 Google Apps 脚本的新手,我根据网络上的一些帖子拼凑了一个脚本。基本上,我已将此脚本分配给收集表单响应的 Google 表格。每次新提交时,都会向受访者发送确认消息。
我通过不属于表单的脚本创建了一个附加列。我还希望将此列作为确认电子邮件的一部分发送,但在添加它时遇到了麻烦。在这种情况下,它是“AC”列或第 29 列。下面是我一直在玩弄的脚本......有人可以提供一些指导,说明如何将 AC 列(#29)中的数据添加到底部我的消息?
提前致谢!
代码:
function SendConfirmationMail(e) {
try {
var ss, cc, sendername, subject, columns;
var message, value, textbody, sender;
// This is your email address and you will be in the CC
cc = Session.getActiveUser().getEmail();
// This will show up as the sender's name
sendername = "My Name";
// Optional but change the following variable
// to have a custom subject for Google Docs emails
subject = "Submission Confirmation";
// This is the body of the auto-reply
message = "Below are your selections:<br><br>";
ss = SpreadsheetApp.getActiveSheet();
columns = ss.getRange(1, 1, 1, ss.getLastColumn()).getValues()[0];
// This is the submitter's email address
sender = e.namedValues["Email Address"].toString();
// Only include form values that are not blank
for ( var keys in columns ) {
var key = columns[keys];
if ( e.namedValues[key] ) {
message += key + ' :: '+ e.namedValues[key] + "<br />";
}
}
textbody = message.replace("<br>", "\n");
GmailApp.sendEmail(sender, subject, textbody,
{cc: cc, name: sendername, htmlBody: message});
} catch (e) {
Logger.log(e.toString());
}
}
【问题讨论】: