在将行插入Google表格时获取电子邮件 [英] Getting email upon inserting rows to google sheets
本文介绍了在将行插入Google表格时获取电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我确实有一个Google工作表,我希望在其中插入任何新行/行时得到通知.
I do have a google sheet where I would like to be notified with any new row/rows inserted to it.
有没有可以处理的扩展程序,或者我应该使用Google Apps脚本,因为它是我的新手,并且从未使用过.
Is there any extension which can handle that, or I should use Google Apps Script as I am new for it and never used it before.
推荐答案
说明:
您正在寻找插入新行时要激活的触发器.
Explanation:
You are looking for a trigger to be activated when you insert a new row.
- 在
Sheet1
中插入新行时,以下脚本将发送电子邮件.随时更改工作表的名称:sh.getName()=='Sheet1'
.
- The following script will send an email when a new row is inserted in
Sheet1
. Feel free to change the name of the sheet:sh.getName()=='Sheet1'
.
function sendEmailRow(e) {
const sh = e.source.getActiveSheet();
if(sh.getName()=='Sheet1' && e.changeType === 'INSERT_ROW') {
MailApp.sendEmail({
to: "example@gmail.com",
subject: "A new row has been added",
body: "New row!"
});
}
}
安装
- 将上述代码复制并粘贴到脚本编辑器( Tools =>脚本编辑器)中的空白脚本中,并保存更改.
- Copy and Paste the above code in a blank script in the script editor (Tools => Script editor) and save the changes.
- 单击:当前项目的触发器
- 创建一个新触发器,然后完全选择以下设置:
- 您的申请已准备就绪!在
Sheet1
中插入新行后,您将向选定的收件人发送电子邮件. - Your application is ready! As soon as you insert a new row in
Sheet1
, you will send an email to the selected recipient.
Installation
您需要为 sendEmailRow
创建一个可安装 onChange
触发器:
You need to create an installable onChange
trigger for sendEmailRow
:
这篇关于在将行插入Google表格时获取电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文