How to send an email on form submission

How to send an email on form submission

In this article, we will show you how you can use the Google Apps Script for sending an email whenever a Google Form is submitted. We will show you how you can include the form submission contents in the email body. 

In order to send an email using the Google Apps Script, you can use the form submission trigger. What is a form submission trigger? It refers to a special type of trigger of Google Apps Script which operates whenever a response is submitted for a Google Form. 

From helping you learn all about how to set up a form submission trigger, and writing the email function to test the trigger, this quick guide on how to send an email on form submission is all you need. Follow these step by step instructions for learning how to send an email on form submission. 

To send an email using Google Apps Script upon Google Form submission, you can use a form submission trigger. A form submission trigger is a special type of Apps Script trigger that runs when a user submits a response to a Google Form.

To set up a form submission trigger, follow these steps:

  1. Open the Script Editor: In Google Forms, go to the “Responses” tab and click the “Script Editor” button. This will open the Script Editor in a new tab.
  2. Create the trigger: In the Script Editor, go to the “Edit” menu and select “Current project’s triggers”. In the “Add trigger” dialog, set the following options:
  • Choose which function to run: Select the function that you want to run when the form is submitted.
  • Select event source: Choose “From form”.
  • Select event type: Choose “On form submit”.
  1. Write the email function: In the Script Editor, write a function that sends an email. You can use the GmailApp.sendEmail() function to send the email. For example:
function sendEmail(e) {
  // Get the form response
  var formResponse = e.response;

  // Get the email address from the form response
  var email = formResponse.getResponseForItem().getResponse();

  // Set the email subject and body
  var subject = "Your email subject";
  var body = "Your email body";

  // Send the email
  GmailApp.sendEmail(email, subject, body);
}

This function will get the email address from the form response and use it to send an email with the specified subject and body.

  1. Test the trigger: Submit a response to the form to test the trigger. If everything is set up correctly, the script will send an email immediately.