我有一个谷歌表格,有两个表格,表单响应和报告:见这里
当表单提交报告表时,会随响应表的最后一个表单或最后一行而发生更改。我想向提交表单的人员发送电子邮件,并在发送电子邮件后将报告表附加为PDF,并在e列中写下已发送的电子邮件:请参阅此处
电子邮件收件人:表单响应列 b 主题:一些文本和表单响应列 a 抄送:ABC@yahoo.com 正文:一些文本和表单响应列 f 附加:报告表作为PDF
我用了这个代码,但它不起作用
function onSubmit(e){
Logger.log('submit ran');
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var lastRow = sheet.getLastRow();
var sa = sheet.getRange(lastRow, 1).getValue();
var sB = sheet.getRange(lastRow, 2).getValue();
var sf = sheet.getRange(lastRow, 6).getValue();
var ssID = SpreadsheetApp.getActiveSpreadsheet().getId();
var sheetgId = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getSheetId();
var email = Session.getUser().getEmail();
var subject = SB;
var body = Sf;
var url = "https://docs.google.com/spreadsheets/d/e/..............................................................=0&single=true&output=pdf";
var result = UrlFetchApp.fetch(url)
var contents = result.getContent();
if (emailSent !== "EMAIL_SENT") {
MailApp.sendEmail(email,subject ,body, {attachments:[{fileName:SB+".pdf", content:contents, mimeType:"application//pdf"}]});
sheet.getRange().setValue("EMAIL_SENT");
SpreadsheetApp.flush();
}
}
我从电子表格>文件>发布到 web>发布报告选项卡获取 pdf 格式的 url
我重写了代码,但得到错误“TypeError:report.getAs不是一个函数(第36行,文件”Code“)"
function onSubmit(e){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getAet();
var calculate = ss.getSheets()[2];
var Responses = ss.getSheets()[0];
var report = ss.getSheets()[1];
var sh = sheet.getRange(lastRow, 8).getValue();
var cell = calculate.getRange("b2");
cell.setFormula(sh);
SpreadsheetApp.flush();
var email = sB;
var subject =
var body = se;
var calculate = ss.getSheets()[2];
vafunction onSubmit(e){
Logger.log('submit ran');
var sheet = ss.getActiveSheet();
var calculate = ss.getSheets()[2];
var Responses = ss.getSheets()[0];
var report = ss.getSheets()[1];
忽然笑
慕丝7291255
相关分类