在Google电子表格中更改值时发送电子邮件

Wal*_*lyG 10 spreadsheet sendmessage google-sheets google-apps-script

我想知道,Google电子表格中的以下内容如何.

  1. 在单元格中值发生更改时发送电子邮件.(价值=已完成).
  2. 将行数据编译到电子邮件中.请参阅下面的代码格式.
  3. 提示用户确认信息.
  4. 如果是,请在下面的代码中向活动用户以及预设用户发送电子邮件.
  5. 这是可选的:使用Email Sent + timestamp更新列(P)16上的行.

嗨塞尔,

尝试实现您提供的代码,但我无法对要修改的内容进行正面或反面,以满足我的需要.

让我用下面的工作流程再次解释一下.

当列K的值发生变化时发送电子邮件.

用于观察列K的部分示例代码

var sheetNameToWatch = "Active Discs";
var columnNumberToWatch = 14; // column A = 1, B = 2, etc.
var valueToWatch1 = "Completed";
var valueToWatch2 = "in progress";

try{
var ss = e.source;
var sheet = ss.getActiveSheet();
var range = e.range;

if (sheet.getName() == sheetNameToWatch && range.columnStart == 
columnNumberToWatch && e.value == valueToWatch)

var confirm = Browser.msgBox
('Email will be sent Team X. Do you want to sent this email?', Browser.Buttons.YES_NO); 
if(confirm!='yes'){return};
// if user click NO then exit the function, else move data
Run Code Online (Sandbox Code Playgroud)

电子邮件将包含该特定行的指定值.防爆.A,B,C,D,E,F,G,H,I,J列中的值.

//Email to be sent if **Inprogess** value is a match:

Var sendEmailTeamA(){

var ProjectName = e.values[0];
var ProjectId = e.values[1];
var ProjectManager = e.values[3];
var Sales = e.values[4];
var Client = e.values[5];
var DiscType = e.values[6];
var DVDFlash = e.values[7];
var Phase = e.values[8];
var Encryption = e.values[9];
var Qty = e.values[11];
var DueDate = e.values[12];
var SpecialInstructions = e.values[13];
var emailAddress = '';
var subject = "DVD Request - " + ProjectName + " " + ProjectId;
var emailBody = "Hi Venue Colombo Team,"
  "\n\nThe following data room(s) will need a disc creation. Please begin bulk save data room and create ISO to upload to the FTP site: " +
  "\nProject Name: " + ProjectName +
  "\nProject ID: " + ProjectId +
  "\nProject Manager: " + ProjectManager +
  "\nPhase: " + Phase +
  "\nDisc Type: " + DiscType +
  "\nEncryption: " + Encryption +
  "\nQuantity: " + Qty +
  "\nClient Due Date: " + DueDate +
  "\nSpecialInstructions: " + SpecialInstructions;
var htmlBody = "Thank you for your <b>Club Ambassador Program</b> report submitted on <i>" + timestamp +
  "</i><br/>&nbsp;<br/>Person Show Submitted this email: " +
  "<br/><font color=\"red\">Your Name:</font> " + activeSessionuser +
  "<br/>Your Email: " + toAddress;
var optAdvancedArgs = {name: "Club Ambassador Program", htmlBody: htmlBody};
MailApp.sendEmail(emailAddress, subject, emailBody, optAdvancedArgs);
}

//Email to be sent if **“Completed”** value is a match:

Var sendEmailTeamB() {

var ProjectName = e.values[0];
var ProjectId = e.values[1];
var ProjectManager = e.values[3];
var Sales = e.values[4];
var Client = e.values[5];
var DiscType = e.values[6];
var DVDFlash = e.values[7];
var Phase = e.values[8];
var Encryption = e.values[9];
var Qty = e.values[11];
var DueDate = e.values[12];
var SpecialInstructions = e.values[13];
var emailAddress = '';
var subject = "DVD Request - " + ProjectName + " " + ProjectId;
var emailBody = "Hi Venue Colombo Team,"
  "\n\nThe following data room(s) will need a disc creation. Please begin bulk save data room and create ISO to upload to the FTP site: " +
  "\nProject Name: " + ProjectName +
  "\nProject ID: " + ProjectId +
  "\nProject Manager: " + ProjectManager +
  "\nPhase: " + Phase +
  "\nDisc Type: " + DiscType +
  "\nEncryption: " + Encryption +
  "\nQuantity: " + Qty +
  "\nClient Due Date: " + DueDate +
  "\nSpecialInstructions: " + SpecialInstructions;
var htmlBody = "Thank you for your <b>Club Ambassador Program</b> report submitted on <i>" + timestamp +
  "</i><br/>&nbsp;<br/>Person Show Submitted this email: " +
  "<br/><font color=\"red\">Your Name:</font> " + activeSessionuser +
  "<br/>Your Email: " + toAddress;
var optAdvancedArgs = {name: "Club Ambassador Program", htmlBody: htmlBody};
MailApp.sendEmail(emailAddress, subject, emailBody, optAdvancedArgs);
}
Run Code Online (Sandbox Code Playgroud)

此工作流程将应用于列K,L,M,N,O.电子邮件将发送到代码中的预设电子邮件地址.我希望这能更好地解释它.我再次感谢你的时间和帮助.

And*_*rts 1

我可以帮助你开始:

  1. 在“资源”>“当前项目的触发器”中添加一个触发器,用于“编辑时”触发 sendEmail()。
  2. ...