日历活动更新时的电子邮件通知

问题描述 投票:0回答:1

我正在使用脚本的这一部分更新一些日历事件:

// Update the event's start and end times with the new date
          event.setTime(newStartTime, newEndTime);

          // Notify guests about the change
          var eventOptions = {
            sendUpdates: "all" // Send updates to all guests
          };

          event.setGuestsCanModify(false); // Optional: Prevent guests from modifying the event

          event.updateEvent(eventOptions); // Update the event with notification

我的来宾列表中的人通常不使用谷歌日历,因此我需要确保他们收到有关活动更改的电子邮件。否则,他们的日历将因不再同时发生的事件而过时。

在最初创建活动时,我发送通知没有任何问题。

当我在谷歌日历中手动进行调整时,通知发送成功...

我看到了删除事件并创建新事件的选项,但这会给参与者的日历留下大量可见的已删除事件...

预先感谢您的帮助。

google-apps-script google-sheets calendar google-calendar-api
1个回答
0
投票
function createEventUpdateTrigger(handler = "captureTheUpdateEventObject") {
  if(ScriptApp.getProjectTriggers().filter(t => t.getHandlerFunction() == handler).filter(e => e).length ==0) {
    ScriptApp.newTrigger(handler).forUserCalendar("calendarId").onEventUpdated().create();
  }
}
function captureTheUpdateEventObject(e) {
  Logger.log(JSON.stringify(e));
  let cal = CalendarApp.getCalendarById(e.calendarId);
  //Put the rest of your code here.
}
© www.soinside.com 2019 - 2024. All rights reserved.