首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google脚本:以线程形式发送电子邮件,而不是单独发送电子邮件

Google脚本:以线程形式发送电子邮件,而不是单独发送电子邮件
EN

Stack Overflow用户
提问于 2022-10-31 09:04:04
回答 1查看 25关注 0票数 0

当前有此脚本可以向相关审批者发送审批请求电子邮件。然而,希望这是作为一个线程发送出去,而不是垃圾邮件的个人电子邮件。有什么我可以插入到我的脚本中来帮助这一点吗?提前感谢!

代码语言:javascript
复制
function sendEmail(){

//drawing from the active sheet.
   var sheet = SpreadsheetApp.getActiveSheet();
  
//setting variables & getting the data from the sheet you are on
  var startRow = 2;  // First row of data to process
  var numRows = sheet.getLastRow();   // Number of rows to process
  var numColumns = sheet.getLastColumn(); //Number of columns to process
  
  var dataRange = sheet.getRange(startRow, 1, numRows-(startRow-1), numColumns);
  var data = dataRange.getValues();
  
  var complete = "sent";
  
for (var i = 0; i < data.length; ++i) {
  var row = data[i];
  var aemail = row[16]; //approver’s email
  var approval = row[13]; //approval column
  var reqrow = row[17]; //req row number
  var emailed = row[18]; //already emailed

//check to see if an email has NOT been sent      
    if (emailed != complete){
      
//check to see if not yet approved
    if(approval == ""){

//When done, it will mark it as sent in the last column
  var sent = sheet.getRange(startRow + i, numColumns); 

//Setting it to send the email to the approver's email
  var email = aemail;
          
//Change the text as desired
    var subject = "Quotation Request";
          
// \n is a line break
    var emailtext = "Hi, " +

    "\n\nYou have quotation request pending your review and approval on row " + reqrow + ".\n" +
    
    "\nPlease go to the link below for your further action.\n" +

    "\nhttps://docs.google.com/spreadsheets/d/x123/edit?usp=sharing \n" +

    "\nThis is an automated email. Thanks."

//Send the email    
    GmailApp.sendEmail(email, subject, emailtext); 
 
//Assign “sent” to to the last cell in the row so the email does not send again
      sent.setValue(complete);
    
        }
    }
  }
}
EN

回答 1

Stack Overflow用户

发布于 2022-10-31 09:14:14

您需要在每个电子邮件中添加参数Message-Id,以实现收件人邮箱中的线程处理。

但是,GmailApp.sendEmail不支持此特性。https://developers.google.com/apps-script/reference/gmail/gmail-app#sendEmail(String,String,String)

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

https://stackoverflow.com/questions/74260922

复制
相关文章

相似问题

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