자동화 빠른 시작

Google Docs 문서 및 문서 작성을 위한 간단한 자동화를 빌드하고 이메일로 문서에 대한 링크를 보냅니다.

목표

  • 스크립트를 설정합니다.
  • 스크립트를 실행합니다.

기본 요건

이 샘플을 사용하려면 다음과 같은 기본 요건이 필요합니다.

  • Google 계정 (Google Workspace 계정은 관리자의 승인이 필요함)
  • 인터넷에 액세스할 수 있는 웹브라우저

스크립트 설정

자동화를 빌드하려면 다음 단계를 따르세요.

  1. Apps Script 편집기를 열려면 다음으로 이동하세요. script.google.com 여기가 처음이라면 script.google.com, 대시보드 보기를 클릭합니다.
  2. 새 프로젝트를 클릭합니다.
  3. 스크립트 편집기에서 코드를 삭제하고 아래 코드를 붙여넣습니다.

    templates/독립 실행형/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. 저장 저장 아이콘를 클릭합니다.

  5. 제목 없는 프로젝트를 클릭합니다.

  6. 스크립트의 이름을 입력하고 이름 바꾸기를 클릭합니다.

스크립트 실행

스크립트를 실행하려면 다음 단계를 따르세요.

  1. 실행을 클릭합니다.
  2. 메시지가 표시되면 스크립트를 승인합니다. OAuth 동의 화면에 확인되지 않은 앱입니다.라는 경고가 표시되면, 고급 >을 선택하여 계속합니다. {프로젝트 이름}(으)로 이동(안전하지 않음)

  3. 스크립트 실행이 완료되면 Gmail 받은편지함을 확인합니다. 을 입력합니다.

  4. 이메일을 열고 링크를 클릭하여 내가 만든 문서를 엽니다.

다음 단계