gpt4 book ai didi

javascript - 发送电子邮件与表中的值进行比较

转载 作者:行者123 更新时间:2023-12-03 06:28:03 26 4
gpt4 key购买 nike

我尝试运行此脚本,但它没有向 userremail 发送任何电子邮件。当用户选择 1,2,3 并进行峰会时,此脚本将比较工作表(第 10 列)中的值并发送差异电子邮件正文。遵循这个脚本

function mutisendemail(e) {
if (e.values[10] == "1") {
var useremail = "test@gmail.com";
var subject = "test1";
var body = "number 1 ";
var photo = DriveApp.getFilesByName('test1.jpg');
MailApp.sendEmail({
to: userEmail,
subject: subject,
body: body,
attachments: [photo.next()]
});
}
if (e.values[10] == "2") {
var useremail = "test@gmail.com";
var subject = "test2";
var body = "number2";
var photo = DriveApp.getFilesByName('test1.jpg');
MailApp.sendEmail({
to: userEmail,
subject: subject,
body: body,
attachments: [photo.next()]
});
}
if (e.values[10] == "3") {
var useremail = "test@gmail.com";
var subject = "test3";
var body = "number3";
var photo = DriveApp.getFilesByName('test1.jpg');
MailApp.sendEmail({
to: userEmail,
subject: subject,
body: body,
attachments: [photo.next()]
});
}
}

最佳答案

请注意变量useremailuserEmail的写法不同。当我修复后,我的收件箱中收到了电子邮件。这是完整的代码:

function sendSimpleEmail(mynumber){
var useremail = "myemail@gmail.com";
var subject = "test"+mynumber;
var body = "number "+mynumber;
var photo = DriveApp.getFilesByName('MyFile.pdf');

MailApp.sendEmail({
to: useremail,
subject: subject,
body: body,
attachments: [photo.next()]
});
}

function sendConditionalEmail(){
var mySheet = SpreadsheetApp.getActiveSpreadsheet();
var myCell = 'B5';
var cellValue = mySheet.getRange(myCell).getValue();
if(cellValue=="1"){
sendSimpleEmail("1");
}
else if(cellValue=="2"){
sendSimpleEmail("2");
}
else if(cellValue=="3"){
sendSimpleEmail("3");
}

关于javascript - 发送电子邮件与表中的值进行比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38559219/

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