/** * 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('ThisdocumentwascreatedbyGoogleAppsScript.');// 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='Linktoyourdoc:'+url;// Send yourself an email with a link to the document.GmailApp.sendEmail(email,subject,body);}catch(err){// TODO (developer) - Handle exceptionconsole.log('Failedwitherror%s',err.message);}}
Clique em Salvar .
Clique em Projeto sem título.
Digite um nome para o script e clique em Renomear.
Executar o script
Para executar o script, siga estas etapas:
Clique em Executar.
Quando solicitado, autorize o script.
Se a tela de consentimento do OAuth mostrar o aviso Este app não está verificado,
continue selecionando Avançado>Acessar {Project Name} (inseguro).
Quando a execução do script for concluída, verifique se o e-mail chegou na sua caixa de entrada do Gmail.
Abra o e-mail e clique no link para abrir o documento que você criou.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2024-12-21 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."]]],[]]