Created
July 28, 2015 21:38
-
-
Save mhawksey/b2298fcd3088698ac33b to your computer and use it in GitHub Desktop.
Modified version of http://stackoverflow.com/a/22200230/1027723 discussed in https://mashe.hawksey.info/?p=16814
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 ??