// The column you want to check if something is entered.
var COLUMNTOCHECK = 10;
// Sheet you are working on
var SHEETNAME = 'Bids';
function sendEmailApprovedBid() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
//checks that we're on the correct sheet.
if(sheet.getSheetName() == SHEETNAME) {
var selectedCell = ss.getActiveCell();
var selectedRow = selectedCell.getRow();
var dataRange = sheet.getRange(selectedRow, 1, 1, 20);
var data = dataRange.getValues();
//checks the column to ensure it is on the one we want to cause the date to appear.
if(selectedCell.getColumn() == COLUMNTOCHECK) {
for (var i = 0; i < data.length; ++i) {
var row = data[i];
var emailAddress = row[7]; // First column
if (emailAddress.match('@') === null){
continue; // skip this iteration of the loop and go to the next one
};
var message = row[16]; // Third column
var subject = 'Your Bid was ACCEPTED';
MailApp.sendEmail(emailAddress, subject, message, {name:'PRIZM', noReply: true});
SpreadsheetApp.flush();
}
}
}
}
“Remove Request Email”
// The column you want to check if something is entered.
var COLUMNTOCHECK = 23;
// Sheet you are working on
var SHEETNAME = 'Requests';
function sendEmailRemovedRequest() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
//checks that we're on the correct sheet.
if(sheet.getSheetName() == SHEETNAME) {
var selectedCell = ss.getActiveCell();
var selectedRow = selectedCell.getRow();
var dataRange = sheet.getRange(selectedRow, 1, 1, 24);
var data = dataRange.getValues();
//checks the column to ensure it is on the one we want to cause the date to appear.
if(selectedCell.getColumn() == COLUMNTOCHECK) {
for (var i = 0; i < data.length; ++i) {
var row = data[i];
var emailAddress = row[7]; // First column
if (emailAddress.match('@') === null){
continue; // skip this iteration of the loop and go to the next one
};
var message = row[23]; // Third column
var subject = 'Your PRIZM Request was removed';
MailApp.sendEmail(emailAddress, subject, message, {name:'PRIZM', noReply: true});
SpreadsheetApp.flush();
}
}
}
}