javascript - Using HtmlService to create email from spreadsheet, but email is empty -
i trying generate email google spreadsheet using following code:
var ss = spreadsheetapp.getactivesheet(); var ui = spreadsheetapp.getui(); function onopen() { ui.createmenu('notifications').additem('new notification', 'createnotification') .addtoui(); } function createnotification() { var me = session.getactiveuser(); var output = htmlservice.createtemplatefromfile('email').evaluate(); mailapp.sendemail({ to: me, subject: 'test email', htmlbody: output.getcontent()}); } function getdate () { return ss.getrange(ss.getlastrow(), 1).getvalue(); } function getescape () { return ss.getrange(ss.getlastrow(), 2).getvalue(); } with following html file template:
<div> <h1>escape notification:</h1> <p>date: <?= getdate();?></p> <p>escape:</p> <p> <?= getescape();?></p> </div> the code runs, , test email. however, when open email there no content.
i have tried couple of different ways. i've tried serving htmloutput .createhtmloutputfromfile() function method outlined above.
i fear missing basic. have spent several hours pouring on apps script api examples , tutorials. nothing i've found here matches problem, either. 1 thing noticed of examples dopost() or doget() calls. can done user interface or web app?
thank in advance help.
change:
htmlbody: output.getcontent() to:
htmlbody: output.getcontent() use capital "b"
Comments
Post a Comment