March 17, 2016

sending email on form submit in google form

How to sending email on form submit in google form using google script code

Sample google form

The google script for sending email on form submit

// Send the google form data on entering submit button
function sendMailOnFormSubmit(e){

     var intendForm = FormApp.getActiveForm(); // you can select from by its id
     var response = intendForm.getResponses();
     var reponseCount = response.length-1;
    // Logger.log(""+indentForm.getResponses());
      var htmlBody = 'Sir, <br/><br/> <p> Sending indent to the following e - mail id   <br/></p> '+response

      var subject =  ' GOOGLE FORM DATA ';
      var optAdvancedArgs = {name: " BRANCH NAME ",bcc :"", htmlBody:

      MailApp.sendEmail("", subject , "Email Body" , optAdvancedArgs);
      Logger.log(" sendMailOnFormSubmit run successfully ");


For Google Form with multiple widgets

      var branchName = response[reponseCount].getItemResponses()[0].getResponse();
      var contactNumber = response[reponseCount].getItemResponses()[1].getResponse();
      var reportedBy = response[reponseCount].getItemResponses()[2].getResponse();
      var complaintType = response[reponseCount].getItemResponses()[3].getResponse();
      var description = response[reponseCount].getItemResponses()[4].getResponse();

Sample google form

Spreadsheet responses reports


Facebook comments