Amphtml: amp-email from GAS (Google Apps Scripts) - possible?

Created on 8 Jan 2020  Â·  2Comments  Â·  Source: ampproject/amphtml

What's the issue?

I'm building an internal request-approval system for my company, and the best scenario I'd like to develop is using the amp dynamic emails in Gmail (our company relies on G Suite services).

I made some few tests, and while sending through https://amp.gmail.dev/playground/ is working fine, when I try to send from GAS the amp content is not showing (Developer settings already enabled, my own address is white-listed). Knowing that GAS has some various limitations, I'd like to know if it's even possible to send automated dynamic emails.

How do we reproduce the issue?

function doGet(e) {          
  var body = HtmlService.createTemplateFromFile('body').evaluate().getContent()

  GmailApp.sendEmail(EMAIL_ADDRESS, new Date(), body, { htmlBody : body})          
}

the html body

<!DOCTYPE HTML>
    <html ⚡4email>
    <head>
      <meta charset="utf-8">
      <script async src="https://cdn.ampproject.org/v0.js"></script>
      <style amp4email-boilerplate>body{visibility:hidden}</style>
      <style amp-custom>
        h1 {
          margin: 1rem;
        }
      </style>
    </head>
    <body>
      <body>
  <amp-img src="https://placekitten.com/800/400"
           alt="Welcome"
           width="800"
           height="400">
  </amp-img>
</body>
    </body>
</html>

What browsers are affected?

Chrome (Gmail)

Which AMP version is affected?

amp-email

Bug amp4email

Most helpful comment

I believe Apps Script's GmailApp doesn't support custom MIME types which are required in order to have the text/x-amp-html part. The docs for sendEmail have this:

Sends an email message with optional arguments. The email can contain plain text or an HTML body. The size of the email (including headers, but excluding attachments) is quota limited.

I suggest reaching out to Apps Script support channels to potentially file a feature request.

All 2 comments

cc @zhangsu @fstanis @ampproject/wg-amp4email

I believe Apps Script's GmailApp doesn't support custom MIME types which are required in order to have the text/x-amp-html part. The docs for sendEmail have this:

Sends an email message with optional arguments. The email can contain plain text or an HTML body. The size of the email (including headers, but excluding attachments) is quota limited.

I suggest reaching out to Apps Script support channels to potentially file a feature request.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gmajoulet picture gmajoulet  Â·  3Comments

torch2424 picture torch2424  Â·  3Comments

mrjoro picture mrjoro  Â·  3Comments

akshaylive picture akshaylive  Â·  3Comments

aghassemi picture aghassemi  Â·  3Comments