I'm trying to edit Google's premade app script that sends emails from a spreadsheet.
I added a new variable currentp
to grab include the URL of the spreadsheet in the emails sent by the script. When I try to run this script I receive the following error:
TypeError: Cannot find function getUrl in object Sheet. (line 17, file "Code")
function sendEmails2() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2;
var numRows = 2;
var dataRange = sheet.getRange(startRow, 1, numRows, 3)
var data = dataRange.getValues();
for (var i = 0; i < data.length; ++i) {
var row = data[i];
var emailAddress = row[0];
var message = row[1];
var currentp = sheet.getUrl() //current spreadsheet page
var emailSent = row[2];
if (emailSent != EMAIL_SENT) {
var subject = "Sending emails from a Spreadsheet";
MailApp.sendEmail(emailAddress, subject, message,currentp); // I would like the URL to be included in the email.
sheet.getRange(startRow + i, 3).setValue(EMAIL_SENT);
SpreadsheetApp.flush();
}
}
}