Automation quickstart  |  Apps Script  |  Google for Developers (2024)

  • Home
  • Google Workspace
  • Apps Script
  • Samples
Stay organized with collections Save and categorize content based on your preferences.

Build and run a simple automation that creates a Google Docs document andemails you a link to the document.

Objectives

  • Set up the script.
  • Run the script.

Prerequisites

To use this sample, you need the following prerequisites:

  • A Google Account (Google Workspace accounts mightrequire administrator approval).
  • A web browser with access to the internet.

Set up the script

To build the automation, take the following steps:

  1. To open the Apps Script editor, go to script.google.com. If this is the first time you've been to script.google.com, click View Dashboard.
  2. Click New project.
  3. Delete any code in the script editor and paste in the code below.

    templates/standalone/helloWorld.gs

    /** * Creates a Google Doc and sends an email to the current user with a link to the doc. */function createAndSendDocument() { try { // Create a new Google Doc named 'Hello, world!' const doc = DocumentApp.create('Hello, world!'); // Access the body of the document, then add a paragraph. doc.getBody().appendParagraph('This document was created by Google Apps Script.'); // Get the URL of the document. const url = doc.getUrl(); // Get the email address of the active user - that's you. const email = Session.getActiveUser().getEmail(); // Get the name of the document to use as an email subject line. const subject = doc.getName(); // Append a new string to the "url" variable to use as an email body. const body = 'Link to your doc: ' + url; // Send yourself an email with a link to the document. GmailApp.sendEmail(email, subject, body); } catch (err) { // TODO (developer) - Handle exception console.log('Failed with error %s', err.message); }}
  4. Click Save Automation quickstart | Apps Script | Google for Developers (3).

  5. Click Untitled project.

  6. Enter a name for your script and click Rename.

Run the script

To run the script, take the following steps:

  1. Click Run.
  2. When prompted, authorize the script.If the OAuth consent screen displays the warning, This app isn't verified,continue by selecting Advanced >Go to {Project Name} (unsafe).

  3. When the script execution completes, check your Gmail inboxfor the email.

  4. Open the email and click the link to open the document that you created.

Next steps

  • Extend Google Docs
  • Extend Google Sheets
  • Extend Google Slides
  • Basic JavaScript features

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-09-06 UTC.

Automation quickstart  |  Apps Script  |  Google for Developers (2024)
Top Articles
The Role of Formal and Informal Education
How to Buy Star Atlas (ATLAS) | Guide To Buying ATLAS | Gate.io
Katie Pavlich Bikini Photos
Gamevault Agent
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Free Atm For Emerald Card Near Me
Craigslist Mexico Cancun
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Doby's Funeral Home Obituaries
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Select Truck Greensboro
Things To Do In Atlanta Tomorrow Night
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Craigslist In Flagstaff
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Walgreens Alma School And Dynamite
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Dmv In Anoka
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Pixel Combat Unblocked
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Rogold Extension
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Weekly Math Review Q4 3
Facebook Marketplace Marrero La
Nobodyhome.tv Reddit
Topos De Bolos Engraçados
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hampton In And Suites Near Me
Stoughton Commuter Rail Schedule
Bedbathandbeyond Flemington Nj
Free Carnival-themed Google Slides & PowerPoint templates
Otter Bustr
Selly Medaline
Latest Posts
Article information

Author: Gregorio Kreiger

Last Updated:

Views: 6099

Rating: 4.7 / 5 (77 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Gregorio Kreiger

Birthday: 1994-12-18

Address: 89212 Tracey Ramp, Sunside, MT 08453-0951

Phone: +9014805370218

Job: Customer Designer

Hobby: Mountain biking, Orienteering, Hiking, Sewing, Backpacking, Mushroom hunting, Backpacking

Introduction: My name is Gregorio Kreiger, I am a tender, brainy, enthusiastic, combative, agreeable, gentle, gentle person who loves writing and wants to share my knowledge and understanding with you.