Reputation: 4093
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:
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.
Upvotes: 1
Views: 1717
Reputation: 2608
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();
Upvotes: 4