gpt4 book ai didi

javascript - OnEdit 需要从列发送电子邮件

转载 作者:行者123 更新时间:2023-12-02 15:08:22 26 4
gpt4 key购买 nike

当 O 列中的单元格提到“已发货”时,我想在 C 列(以及相应的行)中发送电子邮件

需要支持才能正确使用此脚本

function sendEmail(e) {
var thisSheet = e.source.getActiveSheet();
if (thisSheet.getName() !== 'CRM' || e.range.columnStart !== 15 || e.range.rowStart == 1 || e.value !== 'Shipped') return;
var body, headers = thisSheet.getRange(1, 1, 1, 6)
.getValues()[0],
thisRow = thisSheet.getRange(e.range.rowStart, 1, 1, 6)
.getValues()[0],
recipientsEMail = (thisSheet.getRange.columnStart !==3 || e.range.rowStart ==1)
.getValues()[0],
recipients = recipientsEMail,
subject = "Your Vehicle is shipped " + e.source.getName(),
body = "",
i = 0;
while (i < 6) {
body += headers[i] +' - ' + thisRow[i] +'\n';
i++;
}

MailApp.sendEmail(recipients, subject, body);
}

My sheet

最佳答案

看看这是否有效:

function sendEmail(e) {
var thisSheet = e.source.getActiveSheet();
if (thisSheet.getName() !== 'CRM' || e.range.columnStart !== 15 || e.range.rowStart == 1 || e.value !== 'Shipped') return;
var body, headers = thisSheet.getRange(1, 1, 1, 15)
.getValues()[0],
thisRow = thisSheet.getRange(e.range.rowStart, 1, 1, 15)
.getValues()[0];
var recipients = thisRow[2];
var subject = "Your Vehicle is shipped " + e.source.getName(),
body = "Dear Customer,\n\nYour vehicle has been shipped from Japan";


MailApp.sendEmail(recipients, subject, body);
}

您没有说明需要使用多少列来构建电子邮件正文,但如果您增加 while 循环中的数量,则可以轻松更改。

关于javascript - OnEdit 需要从列发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34966547/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com