问题
Whenever a cell in column G of my spreadsheet is changed to "paid", I would like emails to be sent to the addresses contained in columns J and K on the same row, with the email subject being column A of that row, and the email message "paid"
I have seen several similar questions, but am a novice user and have trouble modifying them to suit my project needs. Any help appreciated!
回答1:
function onEdit(e) {
var sh=e.range.getSheet();
if(e.range.columnStart==7 && e.value.toLowerCase()=='paid' && sh.getName()=='Sheet Name') {
var vA=sh.getRange(e.range.rowStart,1,1,sh.getLastColumn()).getValues()[0];
var recipient=Utilities.formatString('%s,%s', vA[9],vA[10]);
var subject=vA[0];
GmailApp.sendEmail(recipient, subject, 'Paid');
}
}
Note: You cannot run this function from the script editor. You will also have to update the SheetName in line 3
Event Objects
Simple Triggers
来源:https://stackoverflow.com/questions/58275064/send-email-to-specific-addresses-based-on-cell-value-change-in-google-sheets