gpt4 book ai didi

google-apps-script - Google Apps 脚本 sendEmail : multiple recipients string?

转载 作者:行者123 更新时间:2023-12-02 00:09:20 27 4
gpt4 key购买 nike

使用 sendEmail,我如何通过组合两个表单字段向多个以逗号分隔的收件人发送电子邮件?当 (lastrow,4) 只有一个值 (abc@domain.com) 而不是多个值 (abc@domain.com, xyz@domain.com) 时,它似乎有效。当前代码如下,所讨论的变量是 recipientsTo

function FormEmail() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheetform = ss.getSheetByName("Sheet1"); // Name of the sheet which contains the results
var lastrow = sheetform.getLastRow();
var recipientsTO = sheetform.getRange(lastrow,3).getValue() + "@domain.com";
var recipientsCC = ""
var team = sheetform.getRange(lastrow,5).getValue();
var datestamp = Utilities.formatDate(sheetform.getRange(lastrow,1).getValue(), "GMT - 5", "yyyy-MM-dd");
var html = "Intro text;

//The questions order in the email will be the order of the column in the sheet
for (var i = 2; i < 11; ++i) {
html = html + "<b>" + sheetform.getRange(1,i).getValue() + "</b><br>";
html = html + sheetform.getRange(lastrow,i).getValue() + "</p><br>";
}

//Add additional emails if entered in form field
if (sheetform.getRange(lastrow,4).getValue() !== "") {
recipientsTO = recipientsTO + "," + sheetform.getRange(lastrow,4).getValue()
}

//CC if response to a question is "Yes"
if (sheetform.getRange(lastrow,10).getValue() == "Yes") {
recipientsCC = "ccEmaIL@gmail.com"
}


MailApp.sendEmail({
to: recipientsTO,
cc: recipientsCC,
subject: "Subject",
htmlBody: html,
});


}

最佳答案

根据 sendEmail(message) 文档,TO 字段只有一个收件人。而 CC 字段可以有多个收件人,用逗号分隔。

http://goo.gl/CGjiJ

`to - String - 收件人的地址。

cc -String - 以逗号分隔的要抄送的电子邮件地址列表`

另一种选择是在该函数中使用 sendEmail(String,String,String,Object) “收件人字符串收件人的地址,以逗号分隔”。

希望这对您有所帮助。

关于google-apps-script - Google Apps 脚本 sendEmail : multiple recipients string?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16341751/

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