0
function sendEmail() {

var ss = SpreadsheetApp.getActiveSpreadsheet()
var sheet1=ss.getSheetByName('Figures');
var sheet2=ss.getSheetByName('Emails');
var charts = sheet1.getCharts();
var subject = sheet1.getRange(05,18).getValue();
var message = sheet1.getRange(7,18).getValue();
var resp = UrlFetchApp.fetch("https://www.googleapis.com/auth/gmail.settings.sharing");
Logger.log(resp.getContentText());
const chartBlobs = new Array(); 
var sig = Gmail.Users.Settings.SendAs.list("me").sendAs[0].signature;
var signature = "<br>" + sig;
const emailImages = {};
var n=sheet2.getLastRow();
var i = 0;
  let emailBody = "<p align='center'>Trace Figures<br>" + message + "</p>"; 
      charts.forEach(function(chart, i){
      chartBlobs[i] = chart.getAs("image/png");
      emailBody += "<p align='center'><img src='cid:chart"+i+"'></p>" + signature; // Aligning the chart to the center of the body in the email
      emailImages["chart"+i] = chartBlobs[i];
  });

Can somebody tell me why this isn't working? I'm trying to get my Gmail signature and include it in the auto email sent, please.

TIA

marc_s
  • 704,970
  • 168
  • 1,303
  • 1,425

1 Answers1

0

I have seen similar threads with the same "var" configuration when utilizing the sendAs, try:

var sig = Gmail.Users.Settings.SendAs.list("me").sendAs.filter(function(account){if(account.isDefault){return true}})[0].signature;

I edited your variable based on the documentation and discussion from this thread

  • I have tried your script but im getting the following error 9:30:42 AM Error ReferenceError: Gmail is not defined sendEmail @ Code.gs:15 – Seamus Clarke Mar 30 '22 at 08:32
  • Oh, make sure you add the Advance Services over the left in your App Script, as the steps from https://developers.google.com/apps-script/guides/services/advanced. Gmail is defined once you the Gmail API advance services. – Ricardo Jose Velasquez Cruz Mar 30 '22 at 16:23