0

I have a google form that has multiple sections and a different set of questions depending on the answer to the first multiple choices. I want to be able to send an email and use a different body message for each of the sections. Below is a snippet of the code

function myFunction(e){
var accountType = e.values[1];
var personName = e.values[2];
var personAddress = e.values[3];
var businessName = e.values[4];
var businessAddress = e.values[5];
var charityName = e.values[6];
var charityAddress = e.values[7];
var subject = "Webform " + accountType + ;
var message = "Application received from " + personName + " of " + personAddress;
MailApp.sendEmail (userEmail, subject, message);
}

I need to have it send a different message (email body) when specific text has been entered into variable "accountType" will create a different email message (body)?

1 Answer 1

0

You will want to use an if/else statement to achieve the desired outcome, threw it together quickly but it should look like what I have below:

  if (accountType = 'account_type-1') {
    var message = "Application received from " + personName + " of " + personAddress;
  } else {
    if (accountType = 'account_type-2') {
      var message = "Different Application received from " + personName + "of " + personAddress;
    }
  }

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.