email - 从谷歌脚本中的单元格获取值

标签 email google-apps-script google-sheets

我正在尝试为我的工作制作工作表。在 Google 脚本中,我为我的工作表创建了“自定义菜单”,以便正确发送电子邮件。但是现在我想从特定单元格中获取值并检查它是否低于,例如,2,发送带有该值的电子邮件。现在,我有这个:

function onOpen() { 
  var ui = SpreadsheetApp.getUi();
  // Or DocumentApp or FormApp.
  ui.createMenu('Custom Menu')
      .addItem('First item', 'menuItem1')
      .addSeparator()
      .addToUi();
}
function menuItem1() {
  SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
     .alert('You clicked the first menu item!');
  if( 'A1' > 3){
  MailApp.sendEmail('luk...@gmail.pl', 'subject', 'message');
  }
}

我不知道如何从这个单元格中获取这个值。这个“如果”只是我正在尝试做的一个例子,我知道它不起作用。提前感谢您的任何帮助。

最佳答案

首先,您需要找到工作表:

var sheet = SpreadsheetApp.getActiveSheet();

然后,您需要指定单元格范围并获取值:
var value = sheet.getRange("A1").getValue();

您可以在此处浏览 API 以获取更多功能:https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app

关于email - 从谷歌脚本中的单元格获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44515670/

相关文章:

python - 使用 python 在 Lotus Notes 中发送邮件

java - 如何收听电子邮件消息

php - 在 php 邮件中发送希伯来语主题去克林贡......?

javascript - 为什么 a 显示 "function getFullYear() { [native code for Date.getFullYear, arity=0] }"而不是方法返回的值?

google-apps-script - 如何解决 Google App Script 中附加组件的时间触发限制?

javascript - 如何使用 Google App Script 将格式化文本从 google 工作表单元格保存到 .rtf?

google-sheets - 是什么导致从 Google 表格创建的 BigQuery 表中出现 `Failure to read the spreadsheet` 错误?

google-api - 谷歌脚本 API : How to apply an onEdit function to every spreadsheet?

php - 无法在 CodeIgniter 4 中发送服务器电子邮件

javascript - 使用 HTML 文件通过应用程序脚本通过文本框查询 Google 电子表格