Google-sheets – Send a Google Forms notification to two differenz email addresses based on

google sheetsgoogle-apps-scriptgoogle-formsjavascript

How can I send an automatic email notification to two different email addresses depending on whether a woman or a man has filled in the form? Please can someone help me with a script to check this situation? I have tried with the following script, but it seems missing a ';' and I don't find the problem. And so I don't know if it works.

function sendEmails() {
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var sheet = SpreadsheetApp.getActiveSheet();
      var lastRow = getLastRow();
      var range = sheet.getRange('A'. lastRow);//location cell
      var gender = range.getValue();

      if (gender === 'female'){
         emailAddress = 'email1@gmail.com'
         }

      elseif (gender === 'male'){
         emailAddress = 'email2@gmail.com'
       }

    MailApp.sendEmail({
         to: emailAddress,
         subject: subject,
         htmlBody: message     
       });
    }

Best Answer

There is an error on elseif. The correct syntax is else if