I'm trying to make it so that when a dropdown cell reads "Send" an email is sent. The email address and message need to be dynamic. The onEdit event is firing but it stops when declaring emailAddress. Why is this happening? I have a lot of VBA experience but much less GAS experience.
/*
* on sheet change, if correct cell
*/
function onEdit(e) {
if (e.range.getSheet().getName() === 'Sheet1') {
var sheet = SpreadsheetApp.getActiveSheet();
if (e.range.getA1Notation() === 'D2' && e.value === 'Send') {
sheet
.getRange('D2')
.clearContent();
logIt('good through here');
var emailAddress = sheet.getRange(2, 1).getValue;
logit('will not show');
var message = sheet.getRange(2, 2).getValue;
var subject = "GAS -- Automated Email";
MailApp.sendEmail(emailAddress, subject, message);
logIt('testEnd');
}
}
}
function logIt(message) {
SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().appendRow([new Date(),message]);
}