我在 Google 电子表格中有一个列(C 列),我想通过电子邮件发送我在例如单元格 D3 中放置了一个“X”。
我在 D3 中放置 X 时设法发送了一封电子邮件,但内容不正确,我最终收到 C 列中每一行的不同邮件,而不是一封包含 C 列所有内容的邮件
任何帮助将非常感激,
编辑:添加了代码,我知道非常业余,我不知道这些东西的分配..
var EMAIL_SENT = "EMAIL_SENT"; //text to put when mail has been sent
function sendEmails2() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 1; // First row of data to process
var numRows = 999; // Number of rows to process
var dataRange = sheet.getRange(1,1, numRows, 3)
//start on row 1 untill numRows
//and 3 columns wide
var data = dataRange.getValues();
//get content of cell A1
for (var i = 0; i < data.length; ++i) {
//start loop to search for data
var row = data[i];
var emailSent = sheet.getRange("F3").getValue();
var readytosend = sheet.getRange("D3").getValue();
if (emailSent != EMAIL_SENT && readytosend == "X") {
MailApp.sendEmail({
to: "mail@mail.com",
subject: "test",
body: row[0],
});
//sends the email
sheet.getRange(startRow + i, 3).setValue(EMAIL_SENT);
//sets email_sent value and increases i to check next row
SpreadsheetApp.flush();
}
}
山姆