我被困在一些代码中,需要一些专家的帮助。我想引用“表单响应”表上的“E”列,它将返回一个人的姓名。可以在“电子邮件”表的“A”列中找到相同的名称。在“电子邮件”表的“B”列中,将是我要发送数据的电子邮件地址。我被困在如何生成这个电子邮件地址上。这是我到目前为止...
function emailData(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var responses = ss.getSheetByName("Form Responses");
var lastRow = responses.getLastRow();
var values = responses.getRange("A"+(lastRow)+":AK"+(lastRow)).getValues();// get the range and values in one step
var headers = responses.getRange("A1:AK1").getValues();// do the same for headers
var recipient = responses.getRange("E"+(lastRow)).getValues();
var emailSheet = ss.getSheetByName("Email");
var names = emailSheet.getRange("A2:A20").getValues();
var emails = emailSheet.getRange("B2:B20").getValues();
var subject = "Capacity Campaign Form";
var message = composeMessage(headers,values);// call the function with 2 arrays as arguments
Logger.log(message);// check the result and then send the email with message as text body
MailApp.sendEmail(recipient,subject,message);
}
function composeMessage(headers,values){
var message = 'Here is the data from the form submission:'
for(var c=0;c<values[0].length;++c){
message+='\n'+headers[0][c]+' : '+values[0][c]
}
return message;
}
我必须向@Serge 提供道具以帮助我处理阵列。唉,你能提供的任何帮助都会很棒!