使用自动拒绝会议的 Google Script Api 创建外出日历活动

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

在 Google 日历中,可以创建“外出”活动,自动拒绝该设置活动的所有未来邀请。

我正在尝试使用 Google script api 创建此类事件,但不知何故我无法做到。

到目前为止,我一直在写这个:

function createOutOfOffice(date){
  var startDate = new Date(date);
  startDate.setHours(0,0,0,0);
  var endDate = new Date(startDate);
  endDate.setDate(startDate.getDate() + 1);

  var outOfOffice = CalendarApp.createEvent('Out of office', startDate, endDate);
  outOfOffice.setVisibility(CalendarApp.Visibility.PUBLIC);
  outOfOffice.removeAllReminders();
}

但它不会创建真正的外出事件,而是生成一个旧的全天事件:

我显然错过了一些东西,因为我创建的活动不会自动拒绝会议。

通读 api 文档,我没有发现任何明显可以帮助我实现我想要的东西。 使用 Google App Scripts 是否可以远程做到这一点?

google-apps-script google-calendar-api
2个回答
4
投票

“外出”事件是 Google 日历的一项相当新的功能,因此,遗憾的是它尚未在 Google Apps 脚本或 Google API 中实现。您可以在here看到相应的功能请求已在 Issuetracker 上提交。您可以给它一颗星以提高可见度,以便该功能有望尽快实现。


0
投票

已于2023年底实现。您必须使用日历服务才能访问API;

CalendarApp
不允许外出活动。

const event = {
    summary: 'Title',
    // "description" parameter is not allowed
    start: {
      dateTime: startTime.toISOString(),
    },
    end: {
      dateTime: endTime().toISOString(),
    },
    eventType: 'outOfOffice',
    outOfOfficeProperties: {
      autoDeclineMode: 'declineOnlyNewConflictingInvitations',
      declineMessage: 'Out of Office',
    },
    transparency: 'opaque',
};

var e = Calendar.Events.insert(event, 'CALENDAR_ID');

参考:https://developers.google.com/calendar/api/guides/calendar-status?hl=en#create-out-of-office

© www.soinside.com 2019 - 2024. All rights reserved.