0

I use chart.getBlob() to retrieve the chart data from Google sheet, and then insert it as an inline image to the email. The chart in Google sheet has two vertical axises, but it only shows one vertical axis in the email.

Code:

function sendNotificationManually(){
  var sheets = SpreadsheetApp.getActive().getSheets();
  for(i in sheets){
    if(sheets[i].getName().toUpperCase().indexOf(HISTORY) >=0){
      var sheet = sheets[i];
      break;
    }
  }
  var chart = sheet.getCharts()[0];
  var template = HtmlService.createTemplateFromFile("template");
  template.url = SpreadsheetApp.getActiveSpreadsheet().getUrl();
  var recipient = Session.getActiveUser().getEmail();
  var subject = SpreadsheetApp.getActive().getName();
  var body = "";
  var options = {
    noReply:true,
    htmlBody:template.evaluate().getContent(),
    inlineImages:{
      chart:chart.getBlob()
    }
  };
  MailApp.sendEmail(recipient, subject, body, options);
}
  • You may want to check this [tutorial](https://mashe.hawksey.info/2015/07/tips-on-emailing-inline-google-charts-from-sheets-using-apps-script/), it said that there is a reported [issue](https://code.google.com/p/google-apps-script-issues/issues/detail?id=3814#c8) : (Google Sheet needs to be shared with anyone with link) and (Missing numeric labels). You can follow their solution on how to properly place a chart as an inline image when sending an email. – Mr.Rebot Sep 16 '17 at 22:07
  • You can also see these related SO post - [post 1](https://stackoverflow.com/a/22200230/5995040) and [post 2](https://stackoverflow.com/a/42821975/5995040) for code reference. Hope this helps. – Mr.Rebot Sep 16 '17 at 22:07
  • Thank you, Mr. Rebot. I think I didn't address my issue clearly, but I don't have enough reputation to post a screenshot. Basically, the chart was sent via email successfully, but the chart is not exactly the same as the one in the original chart in Google Sheet. My chart in Google Sheet has 2 vertical axises, but it was converted to 1 vertical axis in the email. – Ashton Fei Sep 18 '17 at 01:49
  • @Mr.Rebot I just posted my screenshots as links. – Ashton Fei Sep 18 '17 at 02:10

0 Answers0