Apps Script 快速入門導覽課程
本文將說明如何使用 Apps Script 傳送含有結構定義的電子郵件給自己,以便測試電子郵件標記。
建立專案
前往 script.google.com。如果這是您第一次造訪 script.google.com
,系統會將您重新導向至資訊頁面。按一下「Start Scripting」,前往指令碼編輯器。在指令碼編輯器中,為空白專案建立指令碼。
將 Code.gs
中的程式碼替換為以下程式碼:
依序選取「File」>「New」>「Html file」,即可建立新的 HTML 檔案。請將檔案命名為 mail_template
,以便與上述 JavaScript 中的參數相符。將 HTML 檔案的內容替換成以下內容:
測試指令碼
如要測試指令碼,請按照下列步驟操作:
- 儲存專案。
- 選取
Code.gs
的分頁。
- 請確認您已在
Select function
下拉式選單中選取函式 testSchemas
。
- 按一下 Apps Script 開發環境中的
Run
。
第一次執行指令碼時,系統會要求你授予授權,之後請重新執行指令碼。指令碼執行完畢後,請查看收件匣,確認是否有你寄給自己的電子郵件,其中包含「Go-To Action」按鈕,如下圖所示:
指令碼的運作方式
testSchemas
函式會從名為 mail_template.html
的檔案讀取 HTML 內容,並將該內容以電子郵件形式傳送給目前已驗證的使用者。如「向 Google 註冊」一文所述,你傳送給自己的所有結構定義都會顯示在 Gmail 中,因此為了測試目的,可以使用指令碼傳送的電子郵件來略過註冊要求。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-12-21 (世界標準時間)。
[null,null,["上次更新時間:2024-12-21 (世界標準時間)。"],[[["This article provides a guide on using Apps Script to send yourself test emails containing schemas for email markup testing."],["The process involves creating a script and an HTML template within a new Apps Script project."],["The script reads the HTML template, which includes schema markup, and sends it as an email to your Gmail account."],["You can test the script by running the `testSchemas` function, which requires authorization for the first execution."],["This method allows for bypassing the registration requirements for schema markup testing by sending emails to yourself."]]],[]]