Search code examples
javascriptgoogle-forms

How do I modify this Google script to pull the email from column E in the Google sheet?


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 Super User 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: ";

Solution

  • Column E is the 5th column. Use the number 5 for the column. var email = s.getRange(2,5).getValue(); Gets the value from the cell in row 2 column 5