Google App脚本:触发电子邮件和使用CC

时间:2013-12-24 11:33:07

标签: forms email google-apps-script google-sheets carbon-copy

我有一个Google电子表格,一旦从表单填充,我希望用户通过电子邮件回复表单的内容。

目前它通过电子邮件发送表单的编辑,但我想首先包括实际完成表单的人,所以ActiveUser。

这是我目前所拥有的适用于当前要求的内容,但有关如何实现此附加功能的任何想法?

function sendFormByEmail() {
// set Form Submit trigger from Resources above
var ss = SpreadsheetApp.getActiveSpreadsheet();
var ssName = ss.getName();
var editors = ss.getEditors().join(",");
var owner = ss.getOwner().getEmail();
var subject = "SBS Helpline Enquiry " + ss.getSheetValues(ss.getLastRow(),2,1,1) + "            Requires Action";
<BR/>
// 'to' below will be the recipients of the emailed form responses
// can be to = any one of ( editors , owner , custom , test) no quotes
// both sides of the = should be the same color (not including 'var')
var to = ss.getEditors()// AFTER TESTING: change to either editors , owner , custom
// no quotes in above
var responses=ss.getActiveSheet();
var width=responses.getLastColumn();
var headers=responses.getRange(1,1,1,width ).getValues()[0];
var data=responses.getRange(responses.getLastRow(),1,1,width ).getValues()[0];
var message="PLEASE FORWARD THIS ENQUIRY TO THE RELEVANT CONTACTS" + "\n\n";
for(var i=0;i<width;i++){message+=headers[i] + ' = '+ data[i] + "\n\n";};
MailApp.sendEmail(to,subject,message); 
};

已解决,使用

to=ss.getSheetValues(ss.getActiveSheet().getLastRow(), 8, 1, 1);

1 个答案:

答案 0 :(得分:0)

有formEmailer https://sites.google.com/site/formemailer/ 无需编写代码,它可以满足您的需求。