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.
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.
ScriptApp.newTrigger("Your function for delay email") .timeBased() .after(60 * 60 * 1000) .create();
– Alma_Matters Commented Jan 2 at 6:10