0
votes

I am using a Google spreadsheet with stores a forms responses. It was working for a bit but has just quit and I am now getting emails saying I have this error:

Cannot find method (class)(class)sendEmail(string, string, string, string, object). (line 32, file "Code")

The first column in my spreadsheet holds the timestamp, then my data is stored right after it. I have pasted my code below:

function onFormSubmit(e) {
   var name = e.values[1];
   var department = e.values[2];
   var email = e.values[3];
   var phone = e.values[4];
   var project = e.values[5];
   var title = e.values[6];
   var description = e.values[7];
   var reach = e.values[8];
   var goal = e.values[9];
   var time = e.values[10];
   var work = e.values[11];


  // change this address to be the address where you want the notification to go 
   var to = "[email protected], [email protected]";
   var subject = "Intake Form Notification";
   var message = "Your Name: " + name + "\n \n";
       message += "Department: " + department + "\n \n";
       message += "Email: " + email + "\n \n";
       message += "Phone Number: " + phone + "\n \n";
       message += "Project title: " + title + "\n \n";
       message += "Project description: \n " + description + "\n \n";
       message += "Who are you trying to reach? \n" + reach + "\n \n";
       message += "Are you trying to achieve a specific goal with your communication efforts?  \n" + goal + "\n \n";
       message += "Is this request time sensitive? \n " + time + "\n \n";
       message += "Are you currently working with someone in Marketing & Communications?  \n" + work + "\n \n";
  var mailOptions = {
       name: name,
       replyTo: email,
   };
MailApp.sendEmail(to, subject, message, mailOptions);
}

My trigger is set to OnFormSubmit >> From spreadsheet >> On Form Submit

1
You should avoid exposing real email adress on the internet, even here on SO. - Serge insas

1 Answers

1
votes

I think it is a small typo. Can you remove the unwanted comma in mailOptions

var mailOptions = {
       name: name,
       replyTo: email //Removed comma
   };