首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google自动电子邮件

Google自动电子邮件
EN

Stack Overflow用户
提问于 2020-09-18 01:40:55
回答 1查看 28关注 0票数 0

代码如下

在发送一些自动电子邮件时遇到问题。我知道如何根据电子表格自动发送电子邮件,但复杂的是,电子邮件需要在交替的情况下发送。

A组和B组每个周日都需要一封电子邮件,告诉他们一周的日程安排。这两组人要么面对面,要么远程,但他们每周都会轮流。

也就是说,A组本周亲自到场,而B组是远程的。接下来的一周,他们将是相反的(A组远程,B组面对面)

对此有什么想法吗?

代码语言:javascript
复制
    function CheckCohortA() 
{
  // Fetch the Cohort
  var CohortRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Cohorts").getRange("C2:C8"); 
  var Cohort = CohortRange.getValue();
  
  // Check Cohort
  if (Cohort = "A"){
    // Fetch the email address
    var emailRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Cohorts").getRange("B2:B8");
    var emailAddress = emailRange.getValues();
  
  //SendEmail
  var sheet = SpreadsheetApp.getActiveSheet();
  var startRow = 2; // Start at second row because the first row contains the data labels
  var numRows = 10000; // Put in here the number of rows you want to process

  // Fetch the range of cells A2:D
  var dataRange = sheet.getRange("A2:ZZ")
  
  // Fetch values for each row in the Range. I modified this after our call on 4/13 and it no references the cells E and F for th subject and message. 
  // May be easier for Principals to navigate and now this code won't have to be touched as long as the rows aren't changed I don't think. 
  var data = dataRange.getValues();
  for (i in data) {
   var row = data[i];
   var name = row[0];
   var emailAddress = row[1]; 
   var subject = row[5];
   var message = row[4]; 
   var CC = row[3];
   MailApp.sendEmail(emailAddress, subject, message,{
         cc: CC
         });
  }
  }
}

EN

回答 1

Stack Overflow用户

发布于 2020-09-18 02:11:42

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63943477

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档