title: Export Google sheet Chart as an image
body: <p>Would you please help on how to export a chart to a image using google script.</p>
  
  <p>I wrote this code but it doesn't work. I'm worrying that the API <strong>getAs</strong> is deprecated.</p>
  
  <pre><code>function TestEmailCharts(){
      var sheet = SpreadsheetApp.getActiveSheet();
  
    var charts = sheet.getCharts();
  
    if(charts.length!=0)
    {
    var chartBlobs=new Array(charts.length); 
    var emailBody="Charts&lt;br&gt;";
    var emailImages={};
    for(var i=0;i&lt;charts.length;i++){
      chartBlobs[i]= charts[i].getAs("image/jpeg").setName("chartBlob"+i);
      emailBody= emailBody + "&lt;img src='cid:chart"+i+"'&gt;&lt;br&gt;";
      emailImages["chart"+i]= chartBlobs[i];
    }
  
    MailApp.sendEmail({
      to: "email@gmail.com",
      subject: "test2",
      htmlBody: emailBody,
      inlineImages:emailImages});
    }
  }
  </code></pre>
  
  <p>To reproduce the problem,  create a Google spread sheet 
  Create a simple chart with some data. </p>
  
  <p>Add this code to scripts. 
  Replace email@gmail.com with your email </p>
  
  <p>Normally you should receive an email with chart image 
  But the problem is that you will receive a email with black image. </p>
  
  <p>Best regards. </p>