本文介绍了Gmail应用脚本从Spreadsheet添加BCC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了此代码,从Google电子表格发送模板电子邮件。我真的需要BCC另一个收件人。我已经检查过Gmail类。这对我来说并不理想。

I have created this code to send a template email from Google Spreadsheet. I really need to BCC another recipient. I have checked out Class Gmail App. It didn't quite make sense to me.

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();
}


}
}


推荐答案

检查可选参数的方法,可以包括 bcc

也有类似的方法 ,可以包含 bcc

示例:

...
var options = {
   bcc: '[email protected], [email protected]'
};
MailApp.sendEmail(emailAddress, subject, message, options);
...

这篇关于Gmail应用脚本从Spreadsheet添加BCC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 20:41