Click here to Skip to main content
12,898,516 members (69,079 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


6 bookmarked
Posted 20 Mar 2012

Outlook 2007 Calendar Preview

, 20 Mar 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
A form region with a calendar preview for outlook 2007


One of the coolest features in Outlook 2010 is the calendar preview. Well, for those of us that are still using Outlook 2007, this is the Calendar Preview.


Our company isn't planning to upgrade to Outlook 2010 any time soon. But still I wanted to have this feature on my Outlook. I have a lot of appointments and need to see my conflicts right away. Switching to the calendar to see the conflict and then coming back to the meeting request is such a waste of time. So I decided to write my own Calendar Preview control and place it on the meeting request. For this, I used a Form Region Control and a Calendar Control that I got from this guy. Thank you Ertan Tike.

Using the code

OK, has I said I am using a VSTO project for Outlook 2007 and a form region that is Adjoining? The code is very simple, again thanks to the great control from Ertan Tike that does all the work of showing a calendar like control. 

Let's start with the Form Region Factory part of the form region control. We need to declare what kind of message class we want to use. Because we are dealing with meeting, we need to use this message class: 


Next, let us look at the FormRegionInitializing event. Here we connect to the Outlook application and to the calendar folder.

private void AppFormRegionFactory_FormRegionInitializing(object sender,
             Microsoft.Office.Tools.Outlook.FormRegionInitializingEventArgs e)
    oApp = new Microsoft.Office.Interop.Outlook.Application();
    oNS = oApp.GetNamespace("MAPI");
    oCalendar = oNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar);

The next thing is the FormRegionShowing event:

private void AppFormRegion_FormRegionShowing(object sender, System.EventArgs e)
        //Get the calendar items
        Microsoft.Office.Interop.Outlook.Items oItems = 
        //Get the current item
        Microsoft.Office.Interop.Outlook.MeetingItem appM = 
        //Get it has an Appointment
        Microsoft.Office.Interop.Outlook.AppointmentItem appItem = 
        //Set the date and time that we want to show (the Appointment date)          
        string startdate = appItem.Start.Date.ToShortDateString() + " 01:00"; 
        string enddate = appItem.Start.Date.ToShortDateString() + " 23:00";
        //Set the calendar control date
        dayView1.StartDate = appItem.Start.Date;
        dayView1.StartHour = appItem.Start.Hour-2;  //show from 2 hours before
        //Set the filter on our calendar items so we get only today meetings
        string filterTodayAppoints = "([Start]>'" + startdate + 
          "' And [End]<='" + enddate + "')";
        oItems.Sort("[Start]", false);
        oItems.IncludeRecurrences = true;
        myRestricted = oItems.Restrict(filterTodayAppoints);
        m_Appointments = new List<Appointment>();
        foreach (Microsoft.Office.Interop.Outlook.AppointmentItem item in myRestricted)
            Appointment m_Appointment = new Appointment();
            m_Appointment.StartDate = item.Start;
            m_Appointment.EndDate = item.End;
            m_Appointment.Title = item.Subject+Environment.NewLine+item.Location+ 
                                  "; " + item.Organizer;
            if (item.Subject == appItem.Subject)
                m_Appointment.BorderColor = Color.Orange;
            //Add the to our list
    catch (Exception ex)

All we got left to do is show our meeting on the calendar control:

private void dayView1_ResolveAppointments(object sender, ResolveAppointmentsEventArgs args)
        List<Appointment> m_Apps = new List<Appointment>();
        foreach (Appointment m_App in m_Appointments)

        args.Appointments = m_Apps;
    catch (Exception ex)

That's it. 

Points of Interest 

If you are not familiar with the Outlook form region, this is a good start, and I think it can be useful for any one that has as many appointments as I have. 


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


About the Author

Ron Levy
Software Developer
Israel Israel
No Biography provided

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170424.1 | Last Updated 20 Mar 2012
Article Copyright 2012 by Ron Levy
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid