当前有此脚本可以向相关审批者发送审批请求电子邮件。然而,希望这是作为一个线程发送出去,而不是垃圾邮件的个人电子邮件。有什么我可以插入到我的脚本中来帮助这一点吗?提前感谢!
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);
}
}
}
}发布于 2022-10-31 09:14:14
您需要在每个电子邮件中添加参数Message-Id,以实现收件人邮箱中的线程处理。
但是,GmailApp.sendEmail不支持此特性。https://developers.google.com/apps-script/reference/gmail/gmail-app#sendEmail(String,String,String)
https://stackoverflow.com/questions/74260922
复制相似问题