【问题标题】:Using CC to add multiple users from sheets cell使用 CC 从工作表单元格添加多个用户
【发布时间】:2019-06-21 15:44:17
【问题描述】:

当我输入 g - 脚本时,我可以看到如何抄送特定的电子邮件。但我希望能够根据表格中的一个单元格添加多个用户,方法是使用 var 代码来调用它们。

我尝试在 CC 语法中添加 var 无效。

  function sendEmails() {
 var sheet = SpreadsheetApp.getActiveSheet();
  var startRow = 2; // First row of data to process
 var numRows = 1; // Number of rows to process
  // Fetch the range of cells A2:B2
  var dataRange = sheet.getRange(startRow, 1, numRows, 3);
  // 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 subject = 'ILPA Request';
var body = row[1]; // Second column
var file = DriveApp.getFileById('xxxxxxxxx');
var copy = row[2];
GmailApp.sendEmail(emailAddress, subject, body, {cc: [copy]}, 
{attachments: [file]});
   }
 }

我希望发送电子邮件并复制所引用单元格中的电子邮件地址,但我收到此错误消息:找不到方法 sendEmail(string,string,string,object,object)。 (第 16 行,文件“321”)。

【问题讨论】:

  • 如果你使用 Logger.log(copy) 会是什么样子?如果您只使用复制而不是 [复制] 怎么办?
  • @J.G.如果我使用 {cc: copy},我会得到同样的错误,如果我使用 (cc: copy),我会得到一个不同的错误代码,要求缺少括号。如果我尝试 cc: copy,则会出现同样的括号错误

标签: google-apps-script google-sheets gmail


【解决方案1】:

知道了,下面的代码解决了我的问题:

GmailApp.sendEmail(emailAddress, subject, body, {cc: copy, attachments: [file]})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-07-06
    • 2021-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多