[2005] - Display Shared Outlook Calendar in Application
Hi All,
I've tried finding articles relating to this question without success. I would like to display a shared outlook calendar within my application which allows the normal functions of an outlook calendar. Any suggestions / links would be much appreciated.
Re: [2005] - Display Shared Outlook Calendar in Application
AFAIK there is no Outlook control like that for use in VB. You will have to recreate it probably using the Outlook Object Model.
Re: [2005] - Display Shared Outlook Calendar in Application
Thanks for the reply. I found a team calendar form that mimics an outlook calendar but it was written in C# and converting it to VB would take forever. Does anyone know of anything similar which has been written in VB?
Re: [2005] - Display Shared Outlook Calendar in Application
There are free utilities and sites that have code converters.
http://tangiblesoftwaresolutions.com is one that offers a free unlimited time trial version.
Re: [2005] - Display Shared Outlook Calendar in Application
Cheers for the link. The project has been converted but when I make changes, the following error message is displayed.
Quote:
Code generation for property 'CalendarItems' failed. Error was: 'Type 'CalendarLibrary.CalendarItem' In Assembly 'CalendarLibrary, Version = 1.0.3071.26008, Culture = neutral, PublicTokenKey = null' is not marked as serializable.
I looked around google and found an article on 'codeproject' which I downloaded and built but I have no idea how to use it. :confused:
Re: [2005] - Display Shared Outlook Calendar in Application
Sounds like the serializable attribute is missing from for the class that contains the CalendarItems property.
Re: [2005] - Display Shared Outlook Calendar in Application
Any suggestions on how to fix it? Would I have have to go back to the source code, add the attribute and re-compile?
Re: [2005] - Display Shared Outlook Calendar in Application
Lets start at the beginning.
Before you converted the C# code you tested it and it compiled and ran? what version is the C# code for and what version of VS are you using?
Re: [2005] - Display Shared Outlook Calendar in Application
The project compiled and ran under C# but I get the same error message in the C# Project (e.g When I change the name of the Form). Not sure what you mean by C# Version but I found v2.0.50727. Visual Studio 2008 is being used for this project.
Re: [2005] - Display Shared Outlook Calendar in Application
Can you post the link to the project? If it gave an error before you converted it then there is a problem with the original code, not the conversion.
Ps, if you dont change the name of the form does it work?
Re: [2005] - Display Shared Outlook Calendar in Application
Link to the file is Here
The form works as expected after it has been compiled. Changing a control name etc then compiling / saving will display that serialization error.
Re: [2005] - Display Shared Outlook Calendar in Application
I'm sure there will be a better way (so ive probably wasted the last 25 mins of my life) but here is one way you could extract the existing appointments from the calendar:
vb.net Code:
'make sure you include this if you are going to try and use this example
Imports Microsoft.Office.Interop
'I just copied and pasted my entire form so this is just the standard windows form class declaration
Public Class Form1
'Declare the outlook objects we are going to use
Dim app As Outlook.Application
Dim calendarcontents As Outlook.MAPIFolder
'Im just using the Form Load event to fill the datagridview
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
app = New Outlook.Application
'Log in to Outlook profile, this must already exist on the PC
app.Session.Logon("Outlook_Profile_Name_Here", "Password_Here", False, True)
'Get the default calendar for this outlook profile
calendarcontents = app.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
'Loop through all items in the calendar and add them to my datagridview control
For i As Integer = 1 To calendarcontents.Items.Count
appointmentgrid.Rows.Add()
appointmentgrid.Rows(i - 1).Cells("starttime").Value = calendarcontents.Items(i).Start
appointmentgrid.Rows(i - 1).Cells("endtime").Value = calendarcontents.Items(i).End
appointmentgrid.Rows(i - 1).Cells("title").Value = calendarcontents.Items(i).subject
Next
End Sub
End Class
In that example I am just adding the start time, end time and subject/title to a DataGrideView control. I'm sure if you really ran out of options you could just create your own calendar and then possibly use the methods I have used above to add existing appointmets to it. Also, in my example I am just getting the default mailbox's calender folder, you could specify a specific mailbox's calendar using the \\mailboxname\calendar format.
If you search google you will find a way to add appointments as well so you could just use your DIY calendar control to add appointments as well.
Note - I added a reference to the Outlook 11.0 Object Library and obviously Outlook needs to be installed on the machine that this would run from or the code will not work. At the end of the day, if you have to resort to this method you might decide its easier to just let the users use Outlook to add appointments instead of doing it through your app as I can see it being quite a bit of work.
Like I said though, someone else will probably have a better solution :)
Re: [2005] - Display Shared Outlook Calendar in Application
Hi chris128,
That would work perfectly but is it possible to update the datagrid based on a certain date. Also, the calendar in question is actually located in a public folder and relies on NT security permissions for access.
Re: [2005] - Display Shared Outlook Calendar in Application
erm yeah you could use the method I described above to loop through all of the calendar appointment items but add an IF statement in that basicaly says if the start date is equal to the date that the user has selected then show the details of the appointment in the datagrid and if not, then hide the details. Hope that makes sense.
To access the shared calendar in a public folder I believe you would just use the FolderPath property and point it to "\\Public Folders\foldername\calendarname"
Re: [2005] - Display Shared Outlook Calendar in Application
You have to transverse the Public folders one level at a time and not use the full path all at once. ;) Also, that is the default public folder name which of course could be named differently.
Re: [2005] - Display Shared Outlook Calendar in Application
Quote:
Originally Posted by RobDog888
You have to transverse the Public folders one level at a time and not use the full path all at once. ;) Also, that is the default public folder name which of course could be named differently.
oh right, I didnt know you could only traverse one folder at a time... how odd.
Re: [2005] - Display Shared Outlook Calendar in Application
Yea, it makes for a pain in coding but you'd figure they would have given some kind of functionality like Explorer can go directly to a complete path. In Outlook you have the GetFolderFromID but you'd have to know/store the .EntryID first of that public folder.
Although you can go like so...
oApp.Session.Folders.Item(0).Folders.Item(0).Folders.Item(0).Name
etc. to drill down the folder path if you know where you need to go.
Re: [2005] - Display Shared Outlook Calendar in Application
Using "oApp.Session.Folders.Item" could cause some grief because the directory structure could be changed at any given time. Is it possible to scan exchange / outlook for what calendars a user has permission to access and then place them in a drop down list?
After selecting one of the calendars, the contents will be displayed.
P.S - How did you go with the link that I posted RobDog888?
Re: [2005] - Display Shared Outlook Calendar in Application
It runs for me but my conversion utility is on my other system so I'll try converting it tomorrow (just stopped by for a quick visit).
If you only changed the control name in the Calendar.cs class then it wil break as the control name is referenced throughout the entire project. You need to change it everywhere to keep it working.
Re: [2005] - Display Shared Outlook Calendar in Application
Quote:
Originally Posted by nolim8ts
Using "oApp.Session.Folders.Item" could cause some grief because the directory structure could be changed at any given time. Is it possible to scan exchange / outlook for what calendars a user has permission to access and then place them in a drop down list?
After selecting one of the calendars, the contents will be displayed.
P.S - How did you go with the link that I posted RobDog888?
This was only in reference to drilling down the public folders as th first three folders do not get renamed once they are set.
Re: [2005] - Display Shared Outlook Calendar in Application
Hi RobDog888,
Any luck in converting the file?