Reputation: 1
I have just started using google apps and I was wondering how to add and use a HTML File in google script editor. I want to use the HTML with CSS as an Email template (i.e personalizing the email). and send the email using:
MailApp.sendEmail("[email protected]", "Hello", "no html", {htmlBody: html});
Upvotes: 0
Views: 187
Reputation: 3778
With HtmlService.createHtmlOutputFromFile(fileName).getContent() you can generate the HTML as with anywhere in apps script, not sure emails will accept CSS though.
MailApp.sendEmail("[email protected]", "Hello", "no html", {htmlBody: HtmlService.createHtmlOutputFromFile(fileName).getContent()});
The HTML also have to be in the APP SCRIPT directory though, if you want to use an external hosted HTML you can use URLFetch() to get the HTML and treat it as such:
var emailHTML = UrlFetchApp.fetch("http://www.example.com/myemail.html").getContent()[0];
Also a more advanced option, you can also upload your HTML directly to Drive, and create a Database with them. Just another choice.
Upvotes: 1