6

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

Noah Martin
  • 1,708
  • 9
  • 35
  • 73
  • If you dont want a special program for that, google calendar can be subscribed / exported - not sure/ via ical URL. Calendar from outlook can be also share via context menu, but I am not sure how to import into google cal – xxxvodnikxxx Feb 02 '18 at 11:07

4 Answers4

8

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": "janets@a830edad9050849NDA1.onmicrosoft.com",
        "Name": "Janet Schorr"
      },
      "Type": "Required"
    }
  ]
}
Gabe
  • 5,997
  • 5
  • 46
  • 92
5

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.

Albert Iordache
  • 409
  • 1
  • 5
  • 15
2

Albert already answered for Google. For Outlook you use either OLE automation or Microsoft Graph.*

Note that the second option is only for Outlook accounts talking to Exchange Server. If you access other mail backends through Outlook you can't use Graph, only use OLE.

* Update feb 2021: The SOAP based Exchange Web Services still work, but if you start something new use the REST based Graph API

Jan Doggen
  • 8,799
  • 13
  • 70
  • 144
  • Thanks for the answer, so I will create some files programmatically and store them within a specific folder? Then what is the procedure? How will I tell to Outlook to get those files? At the other side the link is for Outlook 97, is it OK even for 2010? – Noah Martin Sep 09 '13 at 09:43
  • 1
    You'll have to look up how OLE automation is done in Java. Look e.g. here http://stackoverflow.com/questions/6679810/is-there-ole-automation-in-java. Then you have to find out how objects are defined in Outlook and use that. Start coding, come back when you have specific questions. The same procedure would apply if you were going to target EWS. As for versions: if you plan to spport Outlook 200 and later, you'll have to use 2007 code and documentation. That's up to you. – Jan Doggen Sep 09 '13 at 10:21
0

You can also use the GCal RESTful API directly. The Java classes actually just wrap the REST calls.
And if you created events in Google Calendar you can subscribe to your Google Calendar from Outlook and have your events imported in Outlook too (although you have to use WebDAV for this)