Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
How to just open user's windows outlook calendar on a button click of my Asp.net web application.

What I have tried:

I tried using interop but did not get anything.
Posted
Updated 4-Aug-17 0:02am

You need to launch a protocol as a hyperlink in the web page, and then Outlook Calendar (if available on the user's machine), would launch by default to take control of the data processing request. The default URI scheme for Outlook Calendar is, outlookcal:, so you need to write the following code in the button.
JavaScript
window.open("outlookcal:");

Your HTML content, precisely would be,
HTML
<button id="outlookCalendarBtn" onclick="window.open('outlookcal:')">
   Open Outlook Calendar
</button>

This code requires Outlook Calendar, installation. If Outlook is not installed — or some other application controls this URI schemes are default handler, results are undefined and not certain. So, take proper countermeasures for those scenarios as well.

Javascript - Open a given URL in a new tab by clicking a button - Stack Overflow[^]
 
Share this answer
 
v2
Comments
Thomas Daniels 4-Aug-17 6:04am    
+5!
Afzaal Ahmad Zeeshan 4-Aug-17 6:05am    
Thank you!
IamWsk 4-Aug-17 6:42am    
Thank you @Afzaal but it opens windows calendar not outlook calendar. How can I change my default handler for it?
Afzaal Ahmad Zeeshan 4-Aug-17 7:24am    
You would need to check for these settings inside the Settings (Windows 10) or inside the Registry (all Windows editions, and versions). There you would be able to change this.

As I have already mentioned, this is all upto the user to manage which application he wants to open for this operations. Sometimes, other applications override this setting by themselves as well. A lot of other certain problems can also be encountered, and there is nothing that a web application can do for this.
IamWsk 4-Aug-17 7:57am    
Yes I have checked with my windows 10 settings only windows calendar is available to select default app for OUTLOOKCAL: protocol. is there any other approach to change setting or open outlook calendar?
Completely agree with solution 2 but it did not worked in my case.

So i created my own custom uri Scheme by creating below registry entry

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\outlookwebcal]
@="URL:Outlook Add Internet Calendar"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\outlookwebcal\shell]
@="open"

[HKEY_CLASSES_ROOT\outlookwebcal\shell\open]

[HKEY_CLASSES_ROOT\outlookwebcal\shell\open\command]
@="\"C:\\Program Files\\Microsoft Office\\root\\office16\\Outlook.exe\" /select outlook:calendar"
 
Share this answer
 
v2
Take a look at this thread: windows - Launch application from a browser - Stack Overflow[^]

A web browser can't launch another application without some sort of extension or plug-in. This is done for security reasons. Think about how many viruses, malware, or damaging actions could take place if browsers launched unknown applications.

If Outlook is installed on their computer, you can have it download a calendar file which would open up the event in their Outlook calendar and allow them to save it.
Difference between iCalendar (.ics) and the vCalendar (.vcs) - Stack Overflow[^]
 
Share this answer
 
Comments
Afzaal Ahmad Zeeshan 4-Aug-17 6:04am    
On the other hand, you can use the Uri Scheme of the Outlook Calendar and launch it through JavaScript dynamically.

Please see Solution 2 for more on this.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900