0

Instead of assigning one static email to the "var email" below (or for that matter multiple emails separated by commas), my question is how do I enter the column E value from the Google Sheet this script is pulling from? Column E contains an email value that varies depending on who is using the form, and we need the script to send to that address specifically each time it is filled out.

Any suggestions would be very helpful. I found similar and related posts, but nothing exactly like this. I also posted in Stack Overflow as I was unsure where this should be housed.

function sendFormByEmail(e) 
{    
  // Enter email address for form respondent below.
  var email = “[email protected]"; 

  var s = SpreadsheetApp.getActiveSheet();
  var headers = s.getRange(1,1,1,s.getLastColumn()).getValues()[0];    
  var message = "";
  var subject = "Instructional Rounds: ";

1 Answer 1

2

You could use a for loop and iterate down Column E, which is column 5. Then insert the cell values into an array.

var data = s.getDataRange().getValues();
//var data = s.getRange(1,5,s.getLastRow(),1).getValues();
var emails = [];

for (var row in data) {
    var cell_value = data[row][5];
    emails.push(cell_value);
}

for (var e in emails) {
    // TODO: Perform operations on emails[]
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.