Autmated emails by delay onsubmiting google form - Stack Overflow

admin2025-05-02  0

I have a Google Form, and I want it to automatically trigger an email 1 hour after the form is submitted. Is this possible?.But I can automate the email without any delay.I want to automatically send email with delay.

I set up a Google Form and used Google Apps Script to send an email 1 hour after form submission. Without the delay, the email is sent successfully, but when I add a delay of 1 hour, the email is not sent as expected.

I have a Google Form, and I want it to automatically trigger an email 1 hour after the form is submitted. Is this possible?.But I can automate the email without any delay.I want to automatically send email with delay.

I set up a Google Form and used Google Apps Script to send an email 1 hour after form submission. Without the delay, the email is sent successfully, but when I add a delay of 1 hour, the email is not sent as expected.

Share Improve this question asked Jan 2 at 5:02 DevendhiranDevendhiran 111 bronze badge 5
  • You could use a single timebased trigger to read the linked sheet and send the emails periodically throughout the day. If you try to create a trigger for each form submission you risk getting into trigger limit quotas. – Cooper Commented Jan 2 at 5:09
  • Please share all the code so we can easily copy it and test. Kindly edit your question to include the code. Thank you! – Alma_Matters Commented Jan 2 at 6:05
  • 1 To programmatically manage triggers and add a delay, include the following code in your script. This creates a time-based trigger that calls the sendDelayedEmail function 1 hour after. ScriptApp.newTrigger("Your function for delay email") .timeBased() .after(60 * 60 * 1000) .create(); – Alma_Matters Commented Jan 2 at 6:10
  • Please provide enough code so others can better understand or reproduce the problem. – Community Bot Commented Jan 2 at 7:26
  • How many submission do you expect per hour? How many triggers can your create before you run into quota limits? – Cooper Commented Jan 2 at 16:45
Add a comment  | 

1 Answer 1

Reset to default 1

Sending Emails with a 1-Hour Delay

To implement a 1 hour delay for sending an email after a Google Form submission,you can utilize the triggers and time based triggers.

You can include the following code in your script. This creates a time-based trigger that calls the sendDelayedEmail function 1 hour after.

  ScriptApp.newTrigger("Change it with your function sendDelayedEmail")
    .timeBased()
    .after(60 * 60 * 1000) 
    .create();

Using the onFormSubmit trigger to detect when the form is submitted and then set up a delayed email using ScriptApp.newTrigger() and Utilities.sleep().

Also don't forget to Link the Script to Form Submission.

1. In the script editor, click on the clock icon (Triggers) in the left panel.

2. Click on Add Trigger.

3. Configure the trigger:

  • Choose which function to run:

  • Select event source:

  • Select type of event: On form submit

4. Save the trigger.

Reference:

Manage triggers programmatically

Installable Triggers

sleep(milliseconds)

Note: If this does not solve the problem you're experiencing, kindly edit your question and provide all the code you have so we can test it. Feel free to leave a comment.

转载请注明原文地址:http://anycun.com/QandA/1746133561a92038.html