Java Google 日历 API: 创建事件时发送电子邮件通知

Java Google Calendar API: Send email notification when creating event

我正在使用 java google 日历 API。每当我创建新活动时 我想向所有与会者发送电子邮件通知

我guess/expect有两种方法可以实现:

  1. 设置为日历属性
  2. 在创建的事件中将其临时设置为 属性

我不关心我使用了这些选项中的哪一个,但我不知道如何以编程方式进行,而且我正在努力寻找任何代码示例。

正如您在 documentation 中所读到的,关于 sendUpdates 参数:

Whether to send notifications about the creation of the new event. Note that some emails might still be sent. The default is false.

Acceptable values are:

  • "all": Notifications are sent to all guests.

  • "externalOnly": Notifications are sent to non-Google Calendar guests only.

  • "none": No notifications are sent. This value should only be used for migration use cases (note that in most migration cases the import method should be used).

您可以按照 insert Example besides the Quickstart 设置以前的配置,但要考虑到 有一个过时的依赖项 让您使用已弃用的 sendNotifications 而不是 sendUpdates:


compile 'com.google.apis:google-api-services-calendar:v3-rev305-1.23.0'

应该是

compile 'com.google.apis:google-api-services-calendar:v3-rev401-1.25.0'


我已经将问题报告给 Google。

假设您已经有了对象创建事件和与会者列表,API 调用应该是:

service.events().insert(calendarId, event).setSendUpdates("all").execute();