/** * Send an email with schemas in order to test email markup. */functiontestSchemas(){try{consthtmlBody=HtmlService.createHtmlOutputFromFile("mail_template").getContent();MailApp.sendEmail({to:Session.getActiveUser().getEmail(),subject:`Test Email markup - ${newDate()}`,htmlBody:htmlBody,});}catch(err){console.log(err.message);}}
依次选择文件 > 新建 > Html 文件 以创建新的 HTML 文件。将该文件命名为 mail_template,以与上述 JavaScript 中的参数匹配。将 HTML 文件的内容替换为以下内容:
<!--
Copyright 2022 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "EmailMessage",
"description": "Check this out",
"potentialAction": {
"@type": "ViewAction",
"target": "https://www.youtube.com/watch?v=eH8KwfdkSqU"
}
}
</script>
</head>
<body>
<p>
This a test for a Go-To action in Gmail.
</p>
</body>
</html>