Krótkie wprowadzenie do automatyzacji
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Utwórz i uruchom automatyzację, która utworzy dokument Google i wyśle Ci e-maila z linkiem do niego.
Cele
Skonfiguruj skrypt.
Uruchom skrypt.
Wymagania wstępne
Aby użyć tego przykładu, musisz spełnić te wymagania wstępne:
Konto Google (w przypadku kont Google Workspace może być wymagana zgoda administratora).
przeglądarkę internetową z dostępem do internetu,
Konfigurowanie skryptu
Aby utworzyć automatyzację:
Aby otworzyć edytor skryptów Google Apps Script, kliknij script.google.com. Jeśli jesteś na stronie script.google.com po raz pierwszy, kliknij Wyświetl panel.
Kliknij Nowy projekt.
Usuń cały kod z edytora skryptów i wklej poniższy kod.
/** * Creates a Google Doc and sends an email to the current user with a link to the doc. */functioncreateAndSendDocument(){try{// Create a new Google Doc named 'Hello, world!'constdoc=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.consturl=doc.getUrl();// Get the email address of the active user - that's you.constemail=Session.getActiveUser().getEmail();// Get the name of the document to use as an email subject line.constsubject=doc.getName();// Append a new string to the "url" variable to use as an email body.constbody=`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 exceptionconsole.log("Failed with error %s",err.message);}}
Kliknij Zapisz.
Kliknij Projekt bez nazwy.
Wpisz nazwę skryptu i kliknij Zmień nazwę.
Uruchamianie skryptu
Aby uruchomić skrypt:
Kliknij Wykonaj.
Gdy pojawi się odpowiedni komunikat, autoryzuj skrypt.
<<../samples/_snippets/oauth.md>>
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2026-04-23 UTC."],[],[]]