I am creating an EVENT and adding it to calendar instance,now I need to add this calendar to mail,so when the next person gets the mail he/she should see the google calendar card.
I have followed the google calendar API documentation for creating events and inserting it to calendar instance.
public void testMethod() throws IOException
{
com.google.api.services.calendar.Calendar service = getCalendarService();
Event event = new Event()
.setSummary("Google I/O 2015")
.setLocation("800 Howard St., San Francisco, CA 94103")
.setDescription("A chance to hear more about Google's developer products.");
DateTime startDateTime = new DateTime("2019-08-20T16:30:00-07:00");
EventDateTime start = new EventDateTime()
.setDateTime(startDateTime)
.setTimeZone("Asia/Calcutta");
event.setStart(start);
DateTime endDateTime = new DateTime("2019-08-24T17:00:00-07:00");
EventDateTime end = new EventDateTime()
.setDateTime(endDateTime)
.setTimeZone("Asia/Calcutta");
event.setEnd(end);
EventAttendee[] attendees = new EventAttendee[] {
new EventAttendee().setEmail("nishikantktyade@example.com"),
};
event.setAttendees(Arrays.asList(attendees));
EventReminder[] reminderOverrides = new EventReminder[] {
new EventReminder().setMethod("email").setMinutes(24 * 60),
new EventReminder().setMethod("popup").setMinutes(10),
};
String calendarId = "nishikantktyade@gmail.com";
service.events().insert(calendarId, event).execute();
System.out.printf(event.toPrettyString());
}
I expect to see the google calendar card with event created when a mail is sent.