Question

I wrote a small Google - Script that sends an email with the desired content, something like that:

function doGet(params) {
  var htmlBody = HtmlService.createHtmlOutputFromFile('tmp').getContent();

 var subject = "Задача#"+params.parameter.p1;
  MailApp.sendEmail({
    to: params.parameter.p2,
    subject: subject,
    htmlBody: htmlBody,
  });
}

Then I published it and got the link to access a Web application. I have another script that sends an email with a button - One Click Action, it looks as follows:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "EmailMessage",
  "action": {
    "@type": "ConfirmAction",
    "name": "Принять",
    "handler": {
      "@type": "HttpActionHandler",
      "url": "http://script.google.com/macros/s/.../exec?p1=param1&p2=example@gmail.com"
    }
  }
}
</script>

But when I click on the button, I get a message that the request has'n been sent. Can I use this link as a handler of One Click Action?

Was it helpful?

Solution

Make sure the script is published and accessible by anyone with the link (or public), as Gmail will send a server-to-server request to that url.

To make sure the script is accessible, you can send a test request with cURL. If that returns without errors, then Gmail will be able to hit the same endpoint.

I tried your code and it works fine when permissions are set correctly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top