选中复选框时需要发送电子邮件(动态电子邮件地址)(真)

Need to send an Email(dynamic email address) when the checkbox is checked(True)

当复选框被选中为 TRUE 时需要发送电子邮件。对于在单元格 C6 和 C8 中具有值的电子邮件正文以及在 C7 中具有收件人电子邮件地址的电子邮件正文(动态并将根据用户更改)。

我厌倦了“MailApp.sendEmail(emailAddress, subject, message);”,但是我失败了。

我未能从所述单元格中获取数据并将其作为邮件发送到收件人的电子邮件地址。

嘿,您可能想为每个单元格中的变量分配一个 getRange('C7').getValue()。我已经使用示例进行了测试,使消息包含分配给名称和 SRF 编号以及下面的示例代码。

function sendemail(){
  const ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("SRF Allotment");
  const emailAddress = ss.getRange("C7").getValue();
  const name = ss.getRange("C8").getValue();
  const srf = ss.getRange("C6").getValue();
  const subject = "Email Subject";
  const message = "Hey " +  name + ",\n\n" + "Please find the SRF: " + srf + " assigned to you.";

  MailApp.sendEmail(emailAddress,subject,message);
}

还建议在您的电子表格中添加一个按钮 UI,这样您就可以发送带有电子表格功能区上的按钮的电子邮件。

参考:https://developers.google.com/apps-script/reference/base/menu