Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Csv 使用简单的谷歌脚本发送电子邮件时遇到问题_Csv_Google Apps Script - Fatal编程技术网

Csv 使用简单的谷歌脚本发送电子邮件时遇到问题

Csv 使用简单的谷歌脚本发送电子邮件时遇到问题,csv,google-apps-script,Csv,Google Apps Script,请有人帮我这个代码。我需要添加不同的电子邮件在1列抄送 希望有人能帮助我 function sendEmails() { var sheet = SpreadsheetApp.getActiveSheet(); var startRow = 2; // First row of data to process var numRows = 20; // Number of rows to process // Fetch the range of cells A2:

请有人帮我这个代码。我需要添加不同的电子邮件在1列抄送

希望有人能帮助我

function sendEmails() {
    var sheet = SpreadsheetApp.getActiveSheet();
    var startRow = 2; // First row of data to process
    var numRows = 20; // Number of rows to process
    // Fetch the range of cells A2:C3
    var dataRange = sheet.getRange(startRow, 1, numRows, 2)
    // Fetch values for each row in the Range.
    var data = dataRange.getValues();
    for (i in data) {
        var row = data[i];
        var emailAddress = row[0]; // First column
        var message = row[1]; // Second column
        var subject = "EXCEPTION REPORT";
        MailApp.sendEmail(emailAddress, subject, message);
    }
}

使用中的选项参数
.sendmail

 function sendEmails() {
    var sheet = SpreadsheetApp.getActiveSheet();
    var startRow = 2; // First row of data to process
    var numRows = 20; // Number of rows to process
    // Fetch the range of cells A2:C3
    var dataRange = sheet.getRange(startRow, 1, numRows, 2)
    // Fetch values for each row in the Range.
    var data = dataRange.getValues();
    for (i in data) {
        var row = data[i];
        var emailAddress = row[0]; // First column
        var ccAddress = row[--index of cc column--];
        var message = row[1]; // Second column
        var subject = "EXCEPTION REPORT";
        MailApp.sendEmail(emailAddress, subject, message, {cc : ccAddress});
    }
}