I have a Google Sheet which sends an email after a specific column has been edited from a trigger. The script works correctly, the problem is that it always sends from my email address (the creator of the trigger). Is it possible to send the email based on a field, not based on who updated the sheet or who created the trigger? So if 1 column is the email address, if that row is updated, it sends from that email. All of these would be enterprise email addresses. My current script is below:
function sendEmails(e) {
var sheet, v, emailAddress, subject, message, time;
sheet = e.source.getActiveSheet();
if (sheet.getName() !== 'Kanban Board' || e.range.columnStart !== 2 || e.value !== 'Done') return;
v = sheet.getRange(e.range.rowStart, 1, 1, sheet.getLastColumn())
.getValues()[0]
emailAddress = 'email1@gmail.com';
time = Utilities.formatString("%07.0f", v[7])
subject = 'Ticket:' + v[8] + ' Action:TechUpdate Hidden:NO Status: EmailClient:NO Reassign: MinutesWorked:' + time + ' BillingRate:';
//subject = 'Ticket:8924' + ' Action:TechUpdate Hidden:NO Status: EmailClient:NO Reassign: MinutesWorked:' + time + ' BillingRate:';
message = 'The task ' + v[5] + ' has been completed.' + v[2];
MailApp.sendEmail(emailAddress, subject, message);
}