如何在单元格中基于附加值“拒绝”添加另一个自动电子邮件回复,然后发送不同的消息“您的请求被拒绝,请提供正确的详细信息”。 请帮助
function sendEmail(e) {
var ss = e.source.getActiveSheet();
if (ss.getName() !== 'Form Responses 1' || e.range.columnStart !== 22 ||
e.value !== 'Completed') return;
var values = ss.getRange(e.range.rowStart, 2, 1, 7)
.getValues()[0];
var headers = ss.getRange(1, 2, 3, 7)
.getValues()[0];
var subject = "New Vendor Request Completed";
var email = values[0];
var cols = [1, 2, 3];
var body = "Hi,\n\n We are please to let you know that the vendor that you have requested has been added to the system of you request. Please read the details below.\n\n"; //add more text if you want to..
for (var i = 1; i < values.length; i++) {
if (cols.indexOf(i) === -1) continue;
body += headers[i] + ": " + values[i] + "\n"
}
MailApp.sendEmail(email, subject, body)
答案 0 :(得分:0)
主要出于我的实践,我将其组合在一起。我希望它能做您想要的。
我从电子邮件部分中分离出了数据收集部分,然后创建了两个不同的电子邮件函数,这些函数由if语句调用,以查找Completed
或Declined
编辑。
function sendEmail(e) {
var ss = e.source.getActiveSheet();
if (ss.getName() !== 'Form Responses 1' || e.range.columnStart !== 22) return;
var values = ss.getRange(e.range.rowStart, 2, 1, 7)
.getValues()[0];
var headers = ss.getRange(1, 2, 3, 7)
.getValues()[0];
if ( e.value == 'Completed') {
completed(values, headers);
}
else if ( e.value == 'Declined') {
declined(values, headers);
}
}
function completed(values, headers) {
var subject = "New Vendor Request Completed";
var email = values[0];
var cols = [1, 2, 3];
var body = "Hi,\n\n We are please to let you know that the vendor that you have requested has been added to the system of you request. Please read the details below.\n\n"; //add more text if you want to..
for (var i = 1; i < values.length; i++) {
if (cols.indexOf(i) === -1) continue;
body += headers[i] + ": " + values[i] + "\n"
}
MailApp.sendEmail(email, subject, body)
}
function declined(values, headers) {
var subject = "New Vendor Request Declined";
var email = values[0];
var cols = [1, 2, 3];
var body = "Hi,\n\n Unfortunately, the vendor that you have requested has not been added to the system of you request. Please read the details below.\n\n"; //add more text if you want to..
for (var i = 1; i < values.length; i++) {
if (cols.indexOf(i) === -1) continue;
body += headers[i] + ": " + values[i] + "\n"
}
MailApp.sendEmail(email, subject, body)
}
让我知道这是否不能满足您的需求。