Home > Mobile >  How do I send an autoreply few minutes after the trigger in Google Apps Script?
How do I send an autoreply few minutes after the trigger in Google Apps Script?

Time:02-26

I have a Google Apps Script code like this where I am sending an autoreply email upon submission of a Google Form. This will send an email immediately after the form submission but is there a way to send this autoreply 5 minutes after the form is submitted in Google Form?

function autoReply(e) {
  var values = e.values;

  ...

  var email = value3;
  var title = "EMAIL TITLE COMES HERE";
  var body = `
DEAR CUSTOMER,

EMAIL BODY COMES HERE
  `;
  GmailApp.sendEmail(email, title, "", {
    htmlBody: body
  });

CodePudding user response:

You can use Utilities.sleep, its max allowed value is 5 minutes/300000 milliseconds

Use this method before the lines which take care of the sending part of operation.

Reference

Utilities.sleep

  • Related