-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathSendCharts.js
25 lines (21 loc) · 921 Bytes
/
SendCharts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// This code is written in Google Apps Script(JavaScript)
// This code sends out charts from Google Sheets
// Charts are created in Google Sheets,using Google Apps Script the charts will be emailed to the specified email.
function emailChartSourceImage(){
const sheet = SpreadsheetApp.getActiveSheet();
const charts = sheet.getCharts();
// setup some variables for our email
const chartBlobs = new Array();
const emailImages = {};
let emailBody = "Charts<br>";
charts.forEach(function(chart, i){
chartBlobs[i] = chart.getAs("image/png");
emailBody += "<p align='center'><img src='cid:chart"+i+"'></p>"; // Alligning the chart to the center of the body in the email
emailImages["chart"+i] = chartBlobs[i];
});
MailApp.sendEmail({
to: "aryanirani123@gmail.com",
subject: "Chart for average marks per subject",
htmlBody: emailBody,
inlineImages:emailImages});
}