简体   繁体   English

Appscript 帮助 onedit email

[英]Appscript help onedit email

I'm pretty new with Appscript and i'm looking for a solution when I complete a task, appscript code on edit will allow me to email whatever email is in the column B with just a simple task email that states the task has been completed.我是 Appscript 的新手,当我完成任务时我正在寻找解决方案,编辑时的 appscript 代码将允许我 email 无论 email 在 B 列中,只有一个简单的任务 email 表明任务已完成.

1个

This script does work but it emails just me whenever there is a change triggered.这个脚本确实有效,但只要触发更改,它就会只给我发电子邮件。 I'd like it just to email the email address in Column B and not me.我只想将它发送到 B 列中的 email 地址 email 而不是我。

i've tried several different scripts but i don't know it well enough to pinpoint the issue or even edit it to fit my needs我已经尝试了几种不同的脚本,但我对它的了解还不足以查明问题所在,甚至无法对其进行编辑以满足我的需要

  function checkValue()
{
 var ss = SpreadsheetApp.getActive();
var sheet = ss.getSheetByName("Sheet1");

var valueToCheck = sheet.getRange("J:J").getValue();

if(valueToCheck="Approved")
{
 MailApp.sendEmail("joes@nhcares.com","Task Completed","1231323"+ 
valueToCheck+ ".");
}
}

this may be too simple of a script, it does email me on edit but I need to tweak it more这可能是一个太简单的脚本,它确实 email 我在编辑时,但我需要更多地调整它

Try this:尝试这个:

function checkValue(e) {
  var sh = e.range.getSheet();
  if (sh.getName() == "Sheet1" && e.range.columnStart == 10 && e.range.rowStart > 1 && e.value == 'Approved') {
    let msg = `${sh.getRange(e.range.rowStart,1,1,sh.getLastColumn()).getDisplayValues().flat().join('\n')}`
    MailApp.sendEmail(sh.getRange(e.range.rowStart,2).getDisplayValue(), "Task Completed", msg);
  }
}

Use installable onEdit trigger使用可安装的 onEdit 触发器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM