我写了这段代码,但是我一生都无法正确验证它。
在行[14]上有定义为var语音邮件的数据。 Google表格中此列中的某些单元格的字符串中包含“ VM”,以表明语音邮件已被保留。该脚本旨在在标记有语音邮件后立即向客户端发送电子邮件。
我在这里做什么错了?
// This constant is written in column S for rows for which an email
// has been sent successfully.
var EMAIL_SENT = 'EMAIL_SENT';
/**
* Sends non-duplicate emails with data from the current spreadsheet.
*/
function sendEmails2() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 857; // First row of data to process
var numRows = 2; // Number of rows to process
// Fetch the range of cells A2:B3
var dataRange = sheet.getRange(startRow, 1, numRows, 3);
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (var i = 0; i < data.length; ++i) {
var row = data[i];
var emailAddress = row[12]; // M column
var message = row[17]; // R column
var emailSent = row[18]; // S column
var voicemailed = row[14]; // O Column, checks to see if 'vm' in cell
if (emailSent !== EMAIL_SENT && voicemailed === voicemailed.REGEXMATCH(voicemailed,"VM")) { // Prevents sending duplicates and checks if row has VM entry
var subject = row[16]; // Q column
MailApp.sendEmail(emailAddress, subject, message);
sheet.getRange(startRow + i, 3).setValue(EMAIL_SENT);
// Make sure the cell is updated right away in case the script is interrupted
SpreadsheetApp.flush();
}
}
}
答案 0 :(得分:0)
请尝试以下操作:
runtimeType
请重试此操作(语音邮件必须是字符串):
if (emailSent !== EMAIL_SENT && RegExp("VM").test(voicemailed))
{
.....
}