Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add events to Outlook Calendar or Google Calendar programmatically?

I have a Java Web application from which the user can add events with date, subject and description (like tasks). I want to send these events to the user's outlook calendar programmatically. Can anyone help me how to achieve this?

PS: If it can be done through Google Calendar tell me how to do that as I am not stuck with outlook :)

like image 686
Noah Martin Avatar asked Sep 09 '13 08:09

Noah Martin


People also ask

How do I automatically add events to Google Calendar?

In Google Calendar settings, go to “Events from Gmail,” and check the box next to "Show events automatically created by Gmail in my calendar."

Can you automatically sync Google Calendar with Outlook?

You can also sync your Google Calendar to your Outlook.com account. If you have a paid G Suite account, you can use the G Suite Sync for Microsoft Outlook tool. Outlook can automatically sync with a Google Calendar when you use Outlook on mobile devices for iOS and Android operating systems.

Is there an API for Outlook calendar?

The calendar API lets you get calendar items of the signed-in user, or users who have shared or delegated their calendars to the signed-in user.


2 Answers

You can now use Outlook Calendar REST API and send requests from your java code.

For the auth flow see this getting started documentation.

Eg. POST to https://outlook.office.com/api/v2.0/me/calendars/{calendar_id}/events a JSON content like:

{
  "Subject": "Discuss the Calendar REST API",
  "Body": {
    "ContentType": "HTML",
    "Content": "I think it will meet our requirements!"
  },
  "Start": {
      "DateTime": "2014-02-02T18:00:00",
      "TimeZone": "Pacific Standard Time"
  },
  "End": {
      "DateTime": "2014-02-02T19:00:00",
      "TimeZone": "Pacific Standard Time"
  },
  "Attendees": [
    {
      "EmailAddress": {
        "Address": "[email protected]",
        "Name": "Janet Schorr"
      },
      "Type": "Required"
    }
  ]
}
like image 160
Gabe Avatar answered Nov 05 '22 01:11

Gabe


Google Calendar seems to be the best choice, as you can use the Google Calendar API. For an example written in Java, look here. Just make sure to note the GCal API usage limits.

Outlook doesn't seem to have some sort of an API, but maybe you can make use of or modify something like the Jpst or java-libpst.

like image 41
Albert Iordache Avatar answered Nov 05 '22 00:11

Albert Iordache