使用谷歌脚本更新日历事件时如何发送通知

时间:2018-01-30 07:54:33

标签: google-apps-script google-sheets google-calendar-api

从Google电子表格我使用Google Script创建活动。创建活动时,我可以向访客发送通知。

有时需要更新一个或多个事件(更改位置,添加/删除人员等)。

更新有效,但我找不到如何向人们发送通知(并非所有访客都在Google日历上)。

虽然我已经在API中看到了可以解决问题的一些事情,但我不知道是否有可能/如何在我编写的脚本中将其包含在内。

请告知。

更新20180130 @ 10:39: 错误:与会者电子邮件无效

function sendInvite(calendarId, eventId, email) {
  var n = eventId.indexOf("@")
  var str = eventId.substring(0,n)
  var event = Calendar.Events.get(calendarId, str);
  Logger.log(event.attendees);
  if(event.attendees) {
    event.attendees.push({
      email: email
    });
  } else {
    event.attendees = new Array({email: email});
  }
  Logger.log('')
  Logger.log(event.attendees)
  Logger.log('')
  Logger.log(event)

  event = Calendar.Events.patch(event, calendarId, str, {
    sendNotifications: true
  });
}

删除标识后显示日志:

18-01-30 10:31:27:213 CET] [{responseStatus=needsAction, email=some@something.com}, {responseStatus=needsAction, email=some@something.com}]
[18-01-30 10:31:27:214 CET] 
[18-01-30 10:31:27:215 CET] [{responseStatus=needsAction, email=some@something.com}, {responseStatus=needsAction, email=some@something.com}, {email=some@something.com,some@something.com}]
[18-01-30 10:31:27:215 CET] 
[18-01-30 10:31:27:216 CET] {reminders={useDefault=true}, summary=test 3, creator={displayName=MyName, self=true, email=some@something.com}, kind=calendar#event, htmlLink=https://www.google.com/calendar/event?eid=************, created=2018-01-30T09:09:15.000Z, attendees=[{responseStatus=needsAction, email=some@something.com}, {responseStatus=needsAction, email=some@something.com}, {email=some@something.com,some@something.com}], iCalUID=***ID***@google.com, start={dateTime=2018-01-31T16:00:00+01:00, timeZone=Europe/Amsterdam}, description=Agenda will be added later, sequence=2, organizer={displayName=MyName, self=true, email=some@something.com}, etag="***etag***", end={dateTime=2018-01-31T17:00:00+01:00, timeZone=Europe/Amsterdam}, location=Thuis, id=***ID***, updated=2018-01-30T09:31:26.758Z, status=confirmed}

0 个答案:

没有答案