0
votes

I'm trying to send HTML emails using Google aps script. I've got the HTML on a google doc which i'm trying to send using the code below. But when I send it I receive it as unformatted text with all the HTML tags displayed. Can anyone tell me how to do this? I'd rather not include the HTML in the script, because there will eventually be an awful lot of it.

var html = UrlFetchApp.fetch('https://docs.google.com/document/d/documentID/export?format=html');

MailApp.sendEmail('emailaddress', subject, null , {htmlBody: html});

Thanks, Bryan

2
Your link seems to be broken - Cooper

2 Answers

0
votes

Here's an example of doing the same thing with a row of spreadsheet data. Link. Don't use css between <style></style> tags. Use inline style="" instead. That seems to work better.

0
votes

Google Script Mail App


The format of your code seems not well-structured, Make sure all the data passed to the: .sendEmail() method is in Curly braces {}. Please reference the code below to see how it works.:


MailApp.sendEmail({
to: "[email protected]", 
subject: "Testing", 
htmlBody:"<h1>Hello there</h1><p>Your HTML Here</p>"});

That's it. You can also send this HTML from external file as:

HTMLService.createTemplateFromFile("fileName")