Outlook Meeting Planner: using WPF in Outlook 2007

  • Comments 8

My name is Saurabh Bhatia. I recently joined the VSTO team as a Program Manager. In this post I would like to talk about one of my first projects here at Microsoft. Over the last couple of months a few members of the VSTO team have been developing a remarkable Outlook add-in. We call it the Outlook Meeting Planner or OMP for short. The basic idea behind the add-in is to extend Outlook's meeting scheduling capabilities so that it is able to easily find conference rooms in the various buildings at Microsoft.

Anyone who works in a large organization knows how painful it is to first find conference rooms that are available and then actually find your way to the conference room through the maze of corporate offices. This has also been a problem for us here at the Microsoft Redmond campus. Luckily, using VSTO we feel we have been able to develop the right solution to this problem. The Outlook Meeting Planner add-in searches through the free-busy information for various conference rooms and displays the available rooms on a floor plan of the office building. This enables us to search for available rooms and also locate them on a map. OMP dynamically queries various enterprise resources to collect all the information including the floor plans. All of this has been made possible by recently released features in Visual Studio 2008. Here's a little sneak peek at what OMP looks like:

OMP_Screen

The OMP screen is an Outlook Form Region which hosts a WPF control to display the interactive map. You can find out more about the Outlook Form Regions and WPF capabilities in VS2008 through MSDN. For this post I would like to focus on some of the tricks we learned while developing this add-in.

Enhance your user experience with WPF in Form Regions

Hosting WPF controls in Outlook Form Regions opens up novel possibilities for creating rich user experiences inside Outlook. The OMP add-in is an excellent example of this capability. One of the challenges facing us was to provide a responsive UI when loading the WPF maps. The OMP team came up with a nifty trick to deliver a smooth load behavior for WPF controls. 

Here's what Igor Zinkovsky, one of the developers of OMP, has to say about this:

The first interaction with a FormRegion happens in FormRegionShowing event handler, so that's where developers are likely to put initialization code for their WPF controls:

// Occurs before the form region is displayed.

private void FormRegion_FormRegionShowing(object sender, System.EventArgs e)

{

   // Perform [perf-intensive] initialization of WPF control

   // like starting animation, loading more XAML, creating shapes, 3D animations, etc

   this.myWpfControl.InitMyControl();

}

If the call to myWpfControl.InitMyControl() takes a long time -  the FormRegion will appear to be frozen until the call returns (giving the impression that opening the FormRegion it-self is hanging).  One way to mitigate this is to remove the expensive initialization from FormRegionShowing handler, and to run the initialization from the Idle loop.  Note that this does not completely solve the UI freeze problem, but it does make it look better to the user.  Instead of the UI being frozen when you open the FormRegion, the FormRegion will open almost immediately and the WPF control will initialize on first Idle loop.  The UI will hang while myWpfControl.InitMyControl() executes, but by this time the FormRegion has already been shown with initial state of the WPF control (which could display something like "Loading").

// Occurs before the form region is displayed.

private void FormRegion_FormRegionShowing(object sender, System.EventArgs e)

{

   System.Windows.Forms.Application.Idle += new EventHandler(Application_Idle);

}

void Application_Idle(object sender, EventArgs e)

{

   try

   {

      // Perform [perf-intensive] initialization of WPF control

      // like starting animation, loading more XAML, creating shapes, 3D animations, etc

      this.myWpfControl.InitMyControl();

   }

   finally

   {

      System.Windows.Forms.Application.Idle -= new EventHandler(Application_Idle);

   }

}

Form Regions and Appointment Items

I would also like to share another useful workaround. If you create an add-in with a Form Region which is attached to an Outlook Appointment Item you will notice some strange behavior when modifying existing appointments.

  • Open an existing meeting from your Calendar.
  • Change something in the Meeting Request like the location/subject/body etc.
  • Close the Meeting Request. Outlook will prompt whether you want to save changes.
  • Choose Don't Save Changes.
  • Open the meeting again. Notice that the changes you made still exist and Outlook has not reverted back to the original Meeting Request.

These changes are lost if you restart Outlook and the item reverts back to its original state. However, in the process Outlook automatically sends out an update to all the recipients of the Meeting Request with the updated information which should not have been saved.

This is a known bug in Outlook programmability which should be fixed soon. Till then all add-in developers can use this trick to make sure that the dirty updates aren't sent out.

This can be achieved by a simple two line magic:

Just call GC.Collect() when the add-in quits. Calling the garbage collector could potentially cause more finalizers to run. To collect the newly disposed object you can call the garbage collector twice.

void ThisAddIn_Quit()

{

   GC.Collect();

   GC.WaitForPendingFinalizers();

   GC.Collect();

   GC.WaitForPendingFinalizers();

}

Calling the Garbage Collector gets rid of any rooted references to the appointment item in the managed code which ensures that the updates aren't sent out. This trick does not solve the problem with the perceived saving of unintended updates (The updates aren't really saved but they will keep showing until you restart Outlook). We will have to wait for Outlook to fix this issue and once it is fixed you will not have to make the call to the Garbage Collector anymore.

Hope you find this information useful in your add-in development adventures. If you haven't already, get Visual Studio 2008 from MSDN.

Special thanks to the OMP team for all the technical insights and to Christin Boyd for convincing me to blog about this experience.

Saurabh Bhatia, Program Manager, Microsoft Corporation

Update on February 16th:  Lots of people have left comments asking for the source code.  The code depends on connecting to some private servers that contain the layout of Microsoft corporate buildings.  There are concerns about publishing the layout of our buildings, as if we will be overrun with criminal masterminds breaking in to my office to steal hardware and all the knick-knacks off my desk.  So we're working on a way to publish the code that removes all references to our servers, and replaces those lines with //todo:  comments.  We also need to find the time to accomplish this task.  We're super busy working on fixing bugs for Service Pack 1 and testing SP1 on 4 operating systems, 2 versions of Office, and 23 foreign languages.  That's quite a test matrix! 

-----
This posting is provided "AS IS" with no warranties, and confers no rights.

Leave a Comment
  • Please add 7 and 4 and type the answer here:
  • Post
  • So is this something we can use or are you just telling us how great you guys are with only a hint of how to build one?

  • There is an interesting post over at blogs.msdn.com

  • This is just for my own reference (aka I have to dig into this) http://blogs.msdn.com/vsto/archive/2008/01/16/outlook-meeting-planner-using-wpf-in-outlook-2007.aspx

  • This is really an interesting article as I am looking at implementing this feature for my organization. I would like to know whether this add-in is available for users having Outlook 2007. Also I would like to know whether it’s possible to port this add-in in Outlook 2003.

    Thanks

    Sanjib

    Email: Sanjib.Biswas@ieee.org

  • the $1000 question... when is the OMP add-in available for general use/download/codeplex?

  • So is this something we can use or are you just telling us how great you guys are with only a hint of how to build one?

  • I think this is an interesting question that I'm speculating with regards to vNext of SharePoint. Also

  • The topic is still as up-to-date as years back...I was just wondering whether you've made some progress on this project?

Page 1 of 1 (8 items)

Outlook Meeting Planner: using WPF in Outlook 2007