This article shows you how to use Apps Script to send yourself an email with schemas in order to test email markup.
Creating the project
Visit script.google.com. If this is the first time you've been to script.google.com
, you'll be redirected to an information page. Click Start Scripting to proceed to the script editor. In the script editor, create a script for a Blank Project.
Replace the code in Code.gs
with the following:
Select File > New > Html file to create a new HTML file. Name the file mail_template
to match the parameter in the JavaScript above. Replace the content of the HTML file with the following:
Testing the script
To test the script:
- Save the project.
- Select the tab for
Code.gs
. - Make sure the function
testSchemas
is selected in theSelect function
dropdown menu. - Click
Run
in the Apps Script development environment.
The first time you run the script you'll be asked to grant authorization, after which you should re-run it. After the script runs, check your inbox for an email sent from yourself with a Go-To Action button, as in the following screenshot:
How does the script work?
The testSchemas
function reads the HTML content from the file named mail_template.html
and sends that content as an email to the currently authenticated user. As explained in Registering with Google, all schemas you send to yourself will be displayed in Gmail, so the email sent by the script can be used to ignore the registration requirements for testing purposes.