Sandeep Mewara">
Click here to Skip to main content
15,389,746 members
Articles / Web Development / HTML
Posted 7 May 2007


65 bookmarked

Import and Export Outlook Appointments (using JavaScript)

Rate me:
Please Sign up or sign in to vote.
4.74/5 (50 votes)
24 Sep 2008CPOL2 min read
How to import and export appointments from Outlook on client-side via JavaScript (for a web application hosted on the server).

Screenshot - OutlookDemo2.png


This article illustrates an example of how to import and export appointments from an Outlook application installed on the client machine and a web-application on the server. The web application being hosted on the server, extraction of appointments can not be done on the server-side as every other user has his/her own list of appointments stored in their Outlook.


I was working on a project that had a requirement to import and export appointments from an Outlook application: saving appointments on the client machine as per the client's choice, and porting appointments from Outlook appointments into the web-application. I tried to find help on the Internet for the same, but failed to find any article written on it.

Using the code

Since we need to extract the appointments on the client-side, we will be using an ActiveX object. Thus, we need to enable the setting to allow ActiveX scripts, as shown below (found under Security Settings of Internet Options):

Screenshot - OutlookDemo1.png

Once an Outlook application is installed on the system and the security setting is done as per above, we are ready to import/export appointments.

// create outlook object
var objOutlook = new ActiveXObject( "Outlook.Application" );

In the case of exporting: for the different items in Outlook, there are fixed item numbers, like:

var olAppointmentItem = 1; //fixed for different properties of outlook object
var objAppointment = objOutlook.CreateItem(olAppointmentItem);

Now, the properties of this object can be set as per required and then saved.

objAppointment.Subject = "Appointment exported to Outlook from a web application"; 
objAppointment.Duration = duration; 

In the case of import: again, for the different items in Outlook, there are fixed item numbers, like:

var outlookFolderCalendar = 9;

We will get all the appointments after creating the MAPI namespace, and give the default folder name.

var objNameSpace = objOutlook.GetNamespace("MAPI");
var outlookFolder = objNameSpace.GetDefaultFolder(outlookFolderCalendar);
var myOutlookItems = outlookFolder.Items;

For example, I have to show the first appointment in the calendar. The different properties can be extracted like:

var dateOfAppointment = myOutlookItems(1).Start;
var bodyOfAppointment = myOutlookItems(1).Body;

The extracted values of each appointment can now be used as per your needs. One thing to note is while extracting appointments from Outlook, we get a prompt like shown below:

Screenshot - Outlookdemo3.png

We need to allow access in order to get the appointments from Outlook.

Points of Interest

Since I was using an ActiveX object, it was difficult getting the different property names required, as ActiveX objects cannot be debugged for quick-watch. It was fun and irritating at the same time to find all the properties required. Not to forget the case-sensitive nature of JavaScript!


First version.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Sandeep Mewara
Software Developer (Senior) Intuit India
India India

Comments and Discussions

QuestionDoes not shows the output Pin
graceselvia8-Jan-13 4:10
Membergraceselvia8-Jan-13 4:10 
QuestionBroser compatiblity Pin
Syedur Rahaman15-Nov-12 6:58
MemberSyedur Rahaman15-Nov-12 6:58 
Questionkdjshfkds Pin
siphosmall15-Jan-12 20:18
Membersiphosmall15-Jan-12 20:18 
QuestionFetch all the appointments Pin
serafen11-Mar-11 14:28
Memberserafen11-Mar-11 14:28 
AnswerRe: Fetch all the appointments Pin
Sandeep Mewara11-Mar-11 20:12
mveSandeep Mewara11-Mar-11 20:12 
GeneralRe: Fetch all the appointments [modified] Pin
serafen12-Mar-11 2:44
Memberserafen12-Mar-11 2:44 
GeneralMy vote of 1 Pin
Ashish Tyagi 4015-Jan-11 9:28
MemberAshish Tyagi 4015-Jan-11 9:28 
QuestionExtra Work? Pin
Shaun Baines17-Dec-10 13:58
MemberShaun Baines17-Dec-10 13:58 
QuestionOutLook 2007 Calendar Type Control Pin
latell15-Oct-09 23:05
Memberlatell15-Oct-09 23:05 
Questionnot working in Safari & Mozila Pin
amit72127-Apr-09 18:52
Memberamit72127-Apr-09 18:52 
AnswerRe: not working in Safari & Mozila Pin
Sandeep Mewara9-Jun-09 19:17
mveSandeep Mewara9-Jun-09 19:17 
GeneralRe: not working in Safari & Mozila Pin
amit72125-Jun-09 20:35
Memberamit72125-Jun-09 20:35 
GeneralUrgently Required ....... Pin
trushitshah23-Apr-09 20:49
Membertrushitshah23-Apr-09 20:49 
AnswerRe: Urgently Required ....... Pin
Sandeep Mewara9-Jun-09 19:18
mveSandeep Mewara9-Jun-09 19:18 
GeneralRe: Urgently Required ....... Pin
trushitshah9-Jun-09 20:01
Membertrushitshah9-Jun-09 20:01 
QuestionUrgently required Pin
MeCode122-Apr-09 19:39
MemberMeCode122-Apr-09 19:39 
AnswerRe: Urgently required Pin
Sandeep Mewara9-Jun-09 19:21
mveSandeep Mewara9-Jun-09 19:21 
QuestionThis code works well and good in IE7. But its not working in IE6. Pin
sannu_eshwari1-Apr-09 19:36
Membersannu_eshwari1-Apr-09 19:36 
AnswerRe: This code works well and good in IE7. But its not working in IE6. Pin
Sandeep Mewara9-Jun-09 19:22
mveSandeep Mewara9-Jun-09 19:22 
GeneralThank u ur code is great Pin
Manprit.bagga5-Mar-09 18:05
MemberManprit.bagga5-Mar-09 18:05 
AnswerRe: Thank u ur code is great Pin
Sandeep Mewara9-Jun-09 19:23
mveSandeep Mewara9-Jun-09 19:23 
GeneralRe Import and Export Outlook appointments using javascript Pin
bsidey10-Jan-09 20:38
Memberbsidey10-Jan-09 20:38 
AnswerRe: Re Import and Export Outlook appointments using javascript Pin
Sandeep Mewara18-Jan-09 19:13
mveSandeep Mewara18-Jan-09 19:13 
GeneralFinding outlook and exporting an event to the outlook Pin
nainakarri17-Dec-08 4:09
Membernainakarri17-Dec-08 4:09 
AnswerRe: Finding outlook and exporting an event to the outlook Pin
Sandeep Mewara21-Dec-08 22:05
mveSandeep Mewara21-Dec-08 22:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.