发送有关下拉列表更改的电子邮件,GAS无法进行 [英] Sending an Email on Dropdown Change, GAS won't Progress

查看:78
本文介绍了发送有关下拉列表更改的电子邮件,GAS无法进行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图做到这一点,以便当下拉单元格显示"Send"(发送)时,发送一封电子邮件.电子邮件地址和消息必须是动态的.onEdit事件正在触发,但在声明emailAddress时停止.为什么会这样呢?我有很多VBA经验,但没有GAS经验.

I'm trying to make it so that when a dropdown cell reads "Send" an email is sent. The email address and message need to be dynamic. The onEdit event is firing but it stops when declaring emailAddress. Why is this happening? I have a lot of VBA experience but much less GAS experience.

/*
 * on sheet change, if correct cell
 */
function onEdit(e) {      
  if (e.range.getSheet().getName() === 'Sheet1') {
    var sheet = SpreadsheetApp.getActiveSheet();
    if (e.range.getA1Notation() === 'D2' && e.value === 'Send') {
        sheet
          .getRange('D2')
            .clearContent(); 
      logIt('good through here');
    var emailAddress = sheet.getRange(2, 1).getValue;
      logit('will not show');
    var message = sheet.getRange(2, 2).getValue;
    var subject = "GAS -- Automated Email";
    MailApp.sendEmail(emailAddress, subject, message);
      logIt('testEnd');
    }
  }    
}

function logIt(message) {
  SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().appendRow([new Date(),message]);
}

推荐答案

在编辑"中无法发送电子邮件:

On Edit cannot send emails:

请注意限制"在此应用程序脚本上,简单触发说明.

Look at "Restrictions" on this apps script simple triggers explanation.

https://developers.google.com/apps-script/guides/triggers

此外,您的将不会显示"该消息未显示,因为您有错字:logit而不是logIt.

Also, your "will not show" message is not displaying because you have a typo: logit rather than logIt.

这篇关于发送有关下拉列表更改的电子邮件,GAS无法进行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆