0

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.

This is what I am trying to do: enter image description here

DevApp
  • 55
  • 1
  • 7
  • So, Are you trying to create calendar invite per email in java? – Dushyant Tankariya Jul 23 '19 at 14:25
  • I have edited the question and added an image of what I am trying,hope that helps:) – DevApp Jul 24 '19 at 03:54
  • Maybe [git link](https://github.com/ical4j/ical4j/wiki/Examples#Creating_a_new_calendar) will help you or possibly you can find your answer from [stackoverflow](https://stackoverflow.com/questions/43278746/send-calendar-invite-per-email-with-java) – Dushyant Tankariya Jul 24 '19 at 04:42
  • @DushyantTankariya Thanks for replying,but I need to use google calendar API?As of now i have a calendar instance with event added to it,so should I add this calendar instance in mail body?will it show invite? – DevApp Jul 24 '19 at 04:52
  • Oh sorry for that, So for google Calander, you can look at [programcreek](https://www.programcreek.com/java-api-examples/?class=com.google.api.services.calendar.model.Event&method=setStart) – Dushyant Tankariya Jul 24 '19 at 04:55
  • @DushyantTankariya I have created the same for using Microsoft outlook API also,I have access token,now can you point me in direction of creating invite(Calendar+Event) and adding it to mail,I have searched it on web but there is no proper example,I don't need the code,even the steps will help:) – DevApp Jul 24 '19 at 12:51

0 Answers0