After what seems like months but in fact has only been.... months, I'm finally ready to release what I hope will be a useful bit of code for anybody wanting to use Outlook 2007 Form Regions.
The RCPI Outlook 2007 Form Region Add-Ins consist of a set of Visual Studio 2005 templates for making working with Form Regions much easier by defining a specialized Outlook 2007 add-in that can host one or more Form Regions. The templates and wizards generate all of the plumbing code needed leaving the developer free to concentrate on the functionality of the form region.
I've also created a quick (~7 minute) video (no longer available). I'll attach a rough transcript at the bottom of this blog post. I'll also be adding a "Behind the scenes" video later in the week to describe the code that comes with the templates that does all the heavy lifting.
Here's the transcript:
Hi, this is Paul Ballard from Rochester Consulting Partnership. If you're like me you probably heard about the new Outlook 2007 form region functionality; the ability to combine custom application logic with Outlook 2007 inspectors, only to be disappointed by the development process which involves fun things like manual registry edits and new XML schemas.
What I'm going to show you today is a set of Visual Studio 2005 Templates for creating an Outlook 2007 add in specifically for hosting Form Regions. These templates are available for both Visual Basic and C# and will hopefully make building and using Form Regions much easier.
To start creating a form region you first have to create the form in Outlook. Do this by clicking on "Tools" then "Forms" and then "Design a form". You can choose any form type, I'm going to choose a Contact. In the form designer window you'll see a new button for Form Regions with two options, either create a new form region or open an existing one. For expediency I'm going to open a simple form region that I've already created. This form region will simulate the features of the Message Header example for form regions that was written for MSDN by Ryan Gregg. You can see that this form region has only a text box for displaying the message headers and a copy button to copy the text to the clipboard. Now I'll save that form region to an OFS file and we're ready to start building our add-in.
When the templates are installed they register themselves in Visual Studio under a specific language, either Visual Basic or C# and then under the Office/Office 2007 Addins section. Here you see the Form Region Add-In project. I'll select that and then it will start to generate some files and then popup a new Wizard window for creating Outlook Form Regions.
The first thing to do in the wizard window is to import the OFS file we just saved from inside Outlook. I'll select this from my hard drive. Then I'll give the form region a more readable header. Next I need to decide if this form region will be adjoining, meaning attached to the bottom of an existing inspector or a separate form. If I choose to use a separate form, I can also import an icon to be used in the button on the Inspector. But in this case I'm going to choose adjoining.
Next I need to choose which of the message class inspectors to associate this form region with. I'm going to choose IPM.Note. Then I'll specify that I want this form region to show up on the Reading Pane and the inspector in Read mode but not compose as there won't be any message headers for that yet. That's all the options I need to set and so I'll generate the code.
You can see that I have a FormRegion.vb file with the template for several methods created. Now to show how much easier this is to use than manual form region creation I'm just going to run this without adding any functionality and you'll see that the form region we defined shows up attached to the correct inspector.
Now all that's left for me to do is to add the functionality for the MessageHeader form region. First I'll start by creating a couple of references to the controls on the form. Next I'll cast those references to the actual controls in the OnInitialize method. I want to be sure to clean up any references I have so in the OnClosing method I set the references to Nothing. One of the functions built into the Form Region class is the IsVisible function which allows the developer to determine if the form region should be displayed for a specific item. Here I'll use the existing functionality from the MSDN article by calling ShowRegionOnItem and passing in the Item object.
Now that I've added the functionality I can hit F5 and run the add-in. Here you can see the message header text is being displayed in the form region in the preview pane as well as in the inspector. I can click on the Copy button and then bring up notepad and copy the message headers from the clipboard.
One of the nicest features of a Form Region add-in is that it can host multiple form regions. Here I'll add a new form region by click on "Add" and then "New Item" and you can see that Form Region appears in the list of items. Selecting this starts the wizard again and I have to choose from the same options as before. I'll attach this blank form region to a Contact inspector just to show that it works. And Now I run this and voila two form regions hosted by the same add-in.
As you can imagine there is quite a few things going on behind the covers to make this all work. I'm not going to go over all of that in this recording though, so if you just want to use Form Regions and don't care about the details then this is all you need to know. Of course if you have any problems or questions feel free to email me at Paul.Ballard@BallardSoftware.com.
Thanks and Enjoy!
Click to download the installer for the RCPI Outlook 2007 Form Region Add-in templates.
While Windows Vista and Office 2007 are generally available to the public now, Microsoft is hosting launch events all of the USA over the next month. But last week several MVPs got the opportunity to visit local retailers and give demos and offer advice on Windows and Vista to customers at major retail outlets like Best Buy, Circuit City, Fry's Electronics, etc. I volunteered to work at Best Buy #167 in The Woodlands, TX (Just north of Houston). They had some nice Vista end cap displays including an early look at the new HP TouchSmartPC which drew a lot of attention. While traffic was light the evenings I worked (the weather in Houston has sucked lately) I am happy to say that I was able to show off Office 2007 to several customers who then decided to buy it.
In addition to those events, I'll also be working the "Official" launch events in Houston on February 13th, Dallas on February 21st, and Austin on March 1st. I'll be in the "Ask the Experts" section, so if you are planning to attend stop by and say hello!