我有一张Google表格,在从触发器编辑特定列后发送电子邮件。该脚本正常工作,问题是它总是从我的电子邮件地址(触发器的创建者)发送。是否可以根据字段发送电子邮件,而不是基于更新工作表的人员或创建触发器的人员?因此,如果1列是电子邮件地址,如果该行已更新,则会从该电子邮件发送。所有这些都是企业电子邮件地址。我目前的脚本如下:
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);
}