How to send automatically, auto generated google form Link/URL

using google apps script i wrote some code that will auto generate google form and a spreadsheet linked to the form to collect responses. also using triggers in apps script i set this script to auto generate a form every week. Everything is working as expected.

Instead of opening the form and using ‘send’ button to send the link/url as e-mail, i want the url of this auto generated form to be sent to a specific email automatically, as soon as it gets generated. searched a lot couldn’t find any leads so far. Is this even possible, if so please do help in finding the solution. TIA.

>Solution :

I believe your goal is as follows.

  • You want to create a new Google Form and retrieve the published link of the created Google Form. And, you want to send it as an email.
  • You want to achieve this using Google Apps Script.

In this case, how about the following sample script?

Sample script:

function myFunction() {
  const form = FormApp.create("sample form"); // Create a new Google Form.
  
  // Retrieve published URL.
  const url = form.getPublishedUrl();
  
  // Send the URL as an email.
  MailApp.sendEmail({
    to: "###", // Please set the email address.
    subject: "sample subject",
    body: url
  });
}
  • When this sample script is run, a new Google Form is created and the published URL is sent as an email.

  • This is a simple sample script. So, please modify this for your actual situation.

References:

Leave a Reply