※ GAC 記事一覧
Google Apps Script(通称:GAS)は、Googleが提供する、Google Workspaceなどのサービスを自動化・連携させるためのプログラミング言語およびプラットフォーム。
https://developers.google.com/apps-script
スクリプトを設定する
以下のURLにアクセスしGoogle Apps Scriptエディタを開く。
script.google.com
[新しいプロジェクト]をクリック
スクリプト エディタ内のコードを削除して、次のコードを貼り付け
[Save] (ディスクのマーク)をクリックし保存
[無題のプロジェクト] をクリックし "HelloWorld" に名前を変更
/**
* 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);
}
}
実行ボタンを押してスクリプトを実行する。
いろいろとセキュリティ関連の確認メッセージが表示される。
正常に実行されると自分のGMailにメールが届く。
メール本文のリンクをクリックするとスクリプトが作成したGoogleドキュメントが開く。
公開:2026.10.02(金) 22:21 くもり 19℃







0 件のコメント:
コメントを投稿