I want to retreive CPC and Spend coloumn values of the last row and send that email on a daily basis. I have successfully retrieved CPC but I am unable to do it for spend coloumn.
Code.gs
function sendEmail () {
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var lr = ss.getLastRow();
var data = ss.getRange(lr,3);
var values = data.getValues();
Logger.log(values);
var message = "Today CPC is " values "and spend is " ;
var email = "[email protected]";
var subject = "CPC Today"
MailApp.sendEmail(email,subject, message);
}
CodePudding user response:
In your script, the value is retrieved from only one column. I thought that this is the reason for your issue. So in this case, how about the following modification?
From:
var data = ss.getRange(lr,3);
var values = data.getValues();
Logger.log(values);
var message = "Today CPC is " values "and spend is " ;
To:
var [[cpc, , spend]] = ss.getRange(lr, 3, 1, 3).getValues();
var message = "Today CPC is " cpc " and spend is " spend;