我想通过Javascript / Google App Script中的API响应向用户发送电子邮件吗?

我正在使用Google Apps脚本从外部API获取数据。我想知道是否有一种方法可以在执行以下代码后从JSON获取发送到G-suite / Gmail上的用户电子邮件的数据。任何有关于如何做到这一点的想法的人吗?

  var url = 'https....';
  var response = UrlFetchApp.fetch(url,options);
  if (response.getResponseCode() === 200) {
  var json = JSON.parse(response);
  var id = json["id"];
  sheet.getRange(2+i,21).setvalue(id);
  sheet.getRange(2+i,22).setvalue(1);
  }
else {
 sheet.getRange(2+i,22).setvalue(2);
fancykee 回答:我想通过Javascript / Google App Script中的API响应向用户发送电子邮件吗?

您可以使用这两个sendEmail函数之一,具体取决于您是希望JSON仅位于正文中[1]还是作为附件[2]。一个简单的例子是:

GmailApp.sendEmail("mike@example.com","current time","The time is:");

[1] https://developers.google.com/apps-script/reference/gmail/gmail-app#sendemailrecipient,-body

[2] https://developers.google.com/apps-script/reference/gmail/gmail-app#sendemailrecipient,-options

本文链接:https://www.f2er.com/3022136.html

大家都在问