【问题标题】:Gmail App Script Add BCC from SpreadsheetGmail 应用脚本从电子表格添加密件抄送
【发布时间】:2013-09-13 05:22:34
【问题描述】:

我已创建此代码以从 Google 电子表格发送模板电子邮件。我真的需要密件抄送另一个收件人。我已经签出了 Class Gmail App。这对我来说不太合理。

var EMAIL_SENT = "EMAIL_SENT";

function onOpen() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();

  var menu = [{
    name: "Send Email",
    functionName: "sendEmails2"
  }];

  ss.addMenu("Send Email", menu);
}

function sendEmails2() {

  var sheet = SpreadsheetApp.getActiveSheet();

  var startRow = 2;  // 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[0];  // First column

var message = "Hello Team,\n\n" + row[1] + " Please do the Following:...";       // Second column

var emailSent = row[2];     // Third column
if (emailSent != EMAIL_SENT) {  // Prevents sending duplicates
  var subject = "Team Email";
  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();
}


}
}

【问题讨论】:

    标签: javascript excel email google-apps-script gmail


    【解决方案1】:

    使用可选参数检查sendEmail(recipient, subject, body, options)方法的版本,可以包括bcc

    Class GmailApp也有类似的方法sendEmail(recipient, subject, body, options),可以包括bcc

    例子:

    ...
    var options = {
       bcc: 'bccmail0@domain.ext, bccmail1@domain.ext'
    };
    MailApp.sendEmail(emailAddress, subject, message, options);
    ...
    

    【讨论】:

    • 似乎不起作用。它是否正确? var bcc = 'bcc: xxxx@gmail.com' MailApp.sendEmail(emailAddress, subject, message, bcc);
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-29
    • 2013-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多