/**
* 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);
}
}
Kliknij Zapisz .
Kliknij Projekt bez tytułu.
Wpisz nazwę skryptu i kliknij Zmień nazwę.
Uruchamianie skryptu
Aby uruchomić skrypt, wykonaj te czynności:
Kliknij Wykonaj.
Gdy pojawi się odpowiedni komunikat, autoryzuj skrypt.
Jeśli na ekranie zgody OAuth pojawi się ostrzeżenie Ta aplikacja nie jest zweryfikowana,
wybierz Zaawansowane>Otwórz projekt {Project Name} (niebezpieczny).
[[["Ł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: 2024-09-03 UTC."],[[["This script automates the creation of a Google Doc and emails you a link for access."],["You'll need a Google Account and web browser to use this automation script."],["The script involves pasting provided code into the Apps Script editor and running it after authorization."],["Upon successful execution, you'll receive an email containing the link to your newly created Google Doc."],["Explore further options to extend functionalities with Google Docs, Sheets, and Slides or learn basic JavaScript."]]],[]]