Google Apps 脚本:无法使用 createEvent() 发送电子邮件

Google Apps Script: Unable to send emails using createEvent()

我有以下代码,与会者无法收到有关该活动的电子邮件。尽管该事件反映在他们的日历中。

    var options = {  
     description: description,
     location: location,
     guests: email_address,
     sendInvites: true
   }
   var event = CalendarApp.getCalendarById(calendarId).createEvent(title,
                start_datetime, end_datetime,
                options);

我也已将 oauthScopes 添加到 appsscript.json。

 "oauthScopes": [
   "https://www.googleapis.com/auth/calendar",
   "https://www.google.com/calendar/feeds"
 ]

这似乎是一个授权问题,但不确定如何解决。

当 运行 来自浏览器编辑器的脚本时,您不需要手动添加任何范围。

你的代码对我来说工作得很好 :) 我添加了一些变量来完成它,但它工作得很好 -

function myFunction() {
  var calendarId = 'self@gmail.com'; // if using your own or default calendar ID
  var description = 'test desc';

  // ref link - https://developers.google.com/apps-script/reference/calendar/calendar-app#advanced-parameters_4  
  var email_address = 'contact1@gmail.com, contact2@gmail.com';
  // comma separated guest list 

  var title = 'test title';
  var start_datetime = new Date();
  var end_datetime = new Date();
  var options = {  
    description: description,
    guests: email_address,
    sendInvites: true
  }
  var event = CalendarApp
  .getCalendarById(calendarId)
  .createEvent(title, start_datetime, end_datetime, options);
}

我的默认清单文件如下所示 -

{
  "timeZone": "Asia/Kolkata",
  "dependencies": {
  },
  "exceptionLogging": "STACKDRIVER"
}

似乎没有添加额外的范围。但是,当我查看 File > Project properties > Scope 时,脚本似乎只添加了一个范围 -

OAuth Scope required by script:

https://www.googleapis.com/auth/calendar

希望对您有所帮助。

编辑备注:忘了加-

也正在接收电子邮件通知