0

I designed an HTML body that is send, using MailApp.sendEmail method, when the function is called. The HTML contains a button that link the email with a file that search in the run moment. Inside the html file I'm trying to run a JS script to change the button reference. I tried in different ways but I couldn't run any kind of script with this Code.gs call.

Code.gs

var htmlBody = HtmlService.createHtmlOutputFromFile("index.html").getContent();

email.html

<button id="linkButton" href="">
   Descargar
</button>

<script>
   var link = document.getElementById("linkButton");
   link.href = "https://www.url.com";
</script>

I wonder if there's another way to run the script inside the HTML email body or if there's another way to call the index.html from the Code.gs where the scripts could be executed. I know that is a simple question but I didn't find any information about how this could be solved.

Reference: google.script.run does not work from HTML template

abasile
  • 11
  • 3
  • I handle this by simply having multiple buttons in the same spot and hiding and showing them as needed. – J. G. Jun 16 '20 at 21:23
  • Thanks for the answer, but my problem is the script execution in the HTML when I call it from the Code.gs. – abasile Jun 16 '20 at 23:49

0 Answers0