【问题标题】:Google App Script: Trigger for email and using CCGoogle App Script:触发电子邮件并使用 CC
【发布时间】:2014-01-12 15:40:34
【问题描述】:

我有一个 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);

【问题讨论】:

  • 这是关于发送电子邮件确认的tutorials 之一。你应该可以修改它并在这里使用?
  • 仍然没有喜悦,看了很多不同的选择。电子邮件地址位于最后一个活动行的第 8 列,但我无法将其提取并包含在收件人行中?
  • 您可以使用 .getLastRow 从最后一行获取值。像'to=ss.getSheetValues(ss.getActiveSheet().getLastRow(), 8, 1, 1);'应该管用。这个有什么具体的错误吗?
  • 谢谢你@Chris - 对它进行排序

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


【解决方案1】:

有formEmailerhttps://sites.google.com/site/formemailer/ 它会做你想做的事,而无需编写代码。

【讨论】:

    猜你喜欢
    • 2020-10-20
    • 1970-01-01
    • 1970-01-01
    • 2016-11-22
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-19
    相关资源
    最近更新 更多