Send email script - issue with var

98 views
Skip to first unread message

Damian Lewandowski

unread,
Sep 22, 2022, 9:04:36 PM9/22/22
to Google Apps Script Community
HI
I have a problem with function var and i don't know what's wrong:

I know that i have to fill the blanks with correct data for spreadsheet etc, but that's not the issue, whatever i put there function var is not working, everytime it get's underlined red and i don't know what to do. Please help me :D!

function sendEmail(// Fetch the email address
var emailRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1").getRange("B2");
var emailAddress = emailRange.getValues();
// Send Alert Email.
var message = "This is your Alert email!"; // Second column
var subject = "Your Google Spreadsheet Alert";
MailApp.sendEmail(emailAddress, subject, message);) {
  
}

Nikola Grujičić

unread,
Sep 23, 2022, 1:20:36 AM9/23/22
to Google Apps Script Community
Did you tried  emailRange.getValue(); instead of  emailRange.getValues();
That way list of values is returned, not a single value.

Damian Lewandowski

unread,
Sep 23, 2022, 6:23:03 PM9/23/22
to Google Apps Script Community
Zrzut ekranu 2022-09-24 002215.png
Thanks for that, awesome, but still the issue is with var itself and i don't know why :(

Damian Lewandowski

unread,
Sep 23, 2022, 7:39:12 PM9/23/22
to Google Apps Script Community
i found the problem and all is good now, thanks for help
Reply all
Reply to author
Forward
0 new messages