简体   繁体   中英

Java Google Calendar API: Send email notification when creating event

I am using java google calendar API. Whenever I create a new event I would like to send an email notification to all attendees .

I guess/expect there are 2 ways how to achieve that:

  1. Set it as the calendar property
  2. Set it ad hoc as property on the created event

I don't care which of these options I use but I don't know how to do it programmatically and I am struggling to find any example of the code.

As you can read in the documentation , about the sendUpdates parameter:

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).

You can follow the insert Example besides the Quickstart to set the previous configuration, but take into account that there is an outdated dependency that makes you use the deprecated sendNotifications instead of sendUpdates :


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

should be

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


I already reported the issue to Google.

Assuming that you already have the object created event, with the list of attendees, the API call should be:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM