當復選框被選中為 TRUE 時需要發送電子郵件。對于具有單元格 C6 和 C8 中的值以及 C7 中的收件人電子郵件地址的電子郵件正文(動態并且將根據用戶而更改)。
我厭倦了“ MailApp.sendEmail(emailAddress, subject, message); ”,但是我失敗了。
我未能從所述單元格中獲取資料并將其作為訊息發送到收件人的電子郵件地址。
uj5u.com熱心網友回復:
嘿,您可能想用getRange('C7').getValue()每個單元格中的 a 分配變數。我已經使用示例進行了測驗,使訊息包含分配給名稱和 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
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/457227.html
