// leave it to jocelyn to reinvent the wheel and build a solution for herself rather than check to see if it already existed :p
// yes, the product team know their stuff, please do not bother re creating the project as this feature already exists. This is for
// demo purposes only :)
I love the integration between my Windows Mobile and my Outlook contacts. I diligently maintain my contacts in Outlook so I can make sure that when I'm on the road and one of my partners call me, I'd have all their business information at hand in case I need to locate them, send something over, etc. Every time I visit a new partner, I come back to the office with a stack of business cards from different people in the organization. I make it a point to add each and every one of them into my contact list. After a while, it felt quite dumb to add different people with the same company name, web and office address, notes etc. True, it's just a few fields but a few multiplied by, say, 10 people in the company is quite taxing, even if it's a copy paste job. So I finally got the spare time today to sit and build something to solve this little problem -- create an outlook add-in.
Last time I tried building an office add in were in the days of VSTO for VS 2005 where you had to manually define the Ribbon in XML, etc. Quite easy actually, but with all the other things I was doing, I couldn't bring myself to sit on it. Now that I heard all that was fixed in VS 2008, I made time for it today. The only difficult part was finding out which object / method creates a new contact, and which ones access the current ones. Hooking it up to the ribbon was a no brainer. So here's what I did:
1. Fire up Visual Studio 2008 and create an Outlook Add-in project
2. Right click on your project and select Add -> New Item...
3. To find the appropriate item easier, first click on Office then Ribbon (Visual Designer)
4. Now you can start visually designing the Ribbon interface. Since this is an Outlook add-in, there will be multiple ribbons to choose from: the ribbon that appears when creating/editing mail, contacts, appointments, etc. In order to specify which one you want to customize, right-click on the ribbon control and view it's properties. The RibbonType is the property that you will want to specify in order to customize the ribbon you want. In this example, I've selected the Microsoft.Outlook.Contact ribbon. (you may, by the way, select multiple ribbons if you want)
5. Now you're all set to use the same drag and drop designer to create your Ribbon UI, much as you would with the forms designer. In this example, I've simply edited the tab name, the group name and added a button to my group. Putting additional tabs and controls, again, is the same experience as in a Windows Forms design experience. And to add functionality to my button-- yep, you guessed it, double click. This will hook up my button to my code.
6. Now for the code. I've commented on the lines that I've added. all the rest, I left as defaults. If you're wondering, yes the namespace and some identifiers changed for this project, I wanted to make it a bit more descriptive :)
7. Hit F5! (of course, I'd have to have Outlook 2007 installed here ) I can now see my custom ribbon visible:
And clicking on it will give me a new dialog, with all the details I specified copied over. The addresses are usually the pain in the *** so that I prioritized.
If you're wondering what that FormRegion1 at the bottom of the window is, that's another control that you can use to customize on top of Outlook. It's basically much like a panel that you can stick your custom user controls into. Form more flexibility on customization, use the Outlook Form Region as your canvas for your components.
Have fun!
p.s. It took me longer to blog about this than to code it.. maybe i should create a live writer plug-in for this. nyehehehe