Did you ever get this resolved? I am having a similar issue where I am 
trying to use htmlservice to render a google visualization, but it doesn't 
show in the email.

Thanks,
Phil

On Monday, March 13, 2017 at 6:59:52 PM UTC-4 Kevin Beattie wrote:

> Hi,
>
> Has anyone experimented with generating chart data on the fly for use with 
> Google App Script?  I've been able to successfully generate the necessary 
> html and javascript as var html, then pass that along to which 
> uses MailApp.sendEmail in Google App script.  The problem with this 
> approach is that the html and javascript isn't executed and is ignored.  If 
> I look at the original email (with the headers), I see the HTML content, 
> but the email is otherwise blank and no chart is visible.
>
> Here's a sample of code:
> // Generate HTML Content
> function genHTML (val1, val2){
>   var htmlbody = "<!DOCTYPE html> <html> <head>";
>   htmlbody = htmlbody + "<script type=\"text/javascript\" src=\"
> https://www.gstatic.com/charts/loader.js\";></script>";
>   htmlbody = htmlbody + "<script type=\"text/javascript\">";
>   htmlbody = htmlbody + "google.charts.load(\'current\', 
> {\'packages\':[\'corechart\']});";
>   htmlbody = htmlbody + "google.charts.setOnLoadCallback(drawChart);";
>   htmlbody = htmlbody + "function drawChart() { ";
>   htmlbody = htmlbody + "var data = 
> google.visualization.arrayToDataTable([";
>   htmlbody = htmlbody + "[\'2-Factor Status\', \'Total\'],";
>   htmlbody = htmlbody + "[\'Enabled\', " + val1 + "],";
>   htmlbody = htmlbody + "[\'Disabled\'," + val2 + "]]);";
>   htmlbody = htmlbody + "      var options = { ";
>   htmlbody = htmlbody + "        title: \'Google 2-Factor Status\'};";
>   htmlbody = htmlbody + "      var chart = new 
> google.visualization.PieChart(document.getElementById(\'piechart\'));";
>   htmlbody = htmlbody + "        chart.draw(data, options);}";
>   htmlbody = htmlbody + "    </script> </head> <body> <div 
> id=\"piechart\" style=\"width: 900px; height: 500px;\"></div> </body> 
> </html>";
>   Logger.log(htmlbody);
>   return htmlbody;
> }
>
> Thanks in advance!
>
> -Kevin
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/f7233c0e-b985-43de-8365-86f6e85695dbn%40googlegroups.com.

Reply via email to