Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Modified from http://stackoverflow.com/a/22200230/1027723
function emailCharts(sheet,emails,emailSubject){
var charts = sheet.getCharts();
if(charts.length==0){
MailApp.sendEmail({
to: emails,
subject: "ERROR:"+emailSubject,
htmlBody: "No charts in the spreadsheet"});
return;
}
var chartBlobs=new Array(charts.length);
var emailBody="Charts<br>";
var emailImages={};
for(var i=0;i<charts.length;i++){
var builder = charts[i].modify();
builder.setOption('vAxis.format', '#');
var newchart = builder.build();
chartBlobs[i]= newchart.getAs('image/png');
emailBody= emailBody + "<p align='center'><img src='cid:chart"+i+"'></p>";
emailImages["chart"+i]= chartBlobs[i];
}
MailApp.sendEmail({
to: emails,
subject: emailSubject,
htmlBody: emailBody,
inlineImages:emailImages});
}
@akkisapra

This comment has been minimized.

Copy link

akkisapra commented Nov 9, 2016

Hi @mshawksey,
I read your article on https://mashe.hawksey.info/2015/07/tips-on-emailing-inline-google-charts-from-sheets-using-apps-script/
I am looking to mail my google chart. but i could not. Can you please help me on understanding your logic and how to use it ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.