Pieter van der Westhuizen

Office 2010 Solutions Module and Add-in Express 2010

I’m sure a lot of us use MS Outlook as our primary application when developing solutions hosted on the MS Office platform or when doing simple productivity enhancing add-ins. Using Outlook is an obvious choice, think about it. It is probably one of the few applications users always have open and use constantly each and every day. So naturally it was Northwind Traders’ (our fictional client for this development) number one choice as the primary application for their Customer, inventory and order management system.

If you have been developing MS Outlook Add-ins for a while, you most probably would have loved to have the ability to add you own pane /page to the left hand navigation pane. Unfortunately that request was something of a holy grail for Outlook developers prior to Outlook 2010. To work around that requirement, Outlook developers had to add their own folders to the existing navigation pane items. This worked to an extent but, speaking from experience, did confuse the users a bit on why there is a Northwind sub folder in their Inbox, and even worse if they already had a folder called Northwind, the add-in did unexpected things.

Well, something I am very excited about in Office Outlook 2010 is the new Solutions Module. This little gem allows developers to add their own pane /page to the Outlook 2010 Navigation Pane. Now, before you get too excited, this is only as long as it contains built-in Outlook items, e.g. calendar, tasks, mail and contacts.

Using Add-in Express 2010 Beta 2, I’ll show you how easy and quick it is to add you own Solutions Module. Let’s get started! Create a new ADX Add-in project or open your existing Northwind project.

Make sure you have the AddinModule designer open, and add a new ADXOLSolutionModule to your designer by either clicking on its toolbar button or selecting it from the designers’ context menu. In case you can’t find it, here’s an image:

Addin Module designer

Next, select the Solutions module component and click on ellipse (…) button next to the Folders property. Click on the Add Folder toolbar button as shown in the following image:

Solution Module folders collection

Change the FolderName property to Northwind and the FolderType to Notes. As you can see you have a list of the built-in Outlook items to choose from. Feel free to change the Image property if you want, then build and register your project.

Start-up Outlook and take a close look at the navigation pane. Notice a new item? If not, you might have to resize the navigation pane or select “show more buttons”. If all went well, your navigation menu should look something similar to this:

Outlook 2010 Navigation pane

You can set the location where the new item needs to be shown in the navigation pane by specifying the NavigationPanePostion property. Here is a screenshot of the result of setting the property to 1:

Custom solution module embedded into Navidation pane

Let us quickly go back to the AddinModule designer and add a few more folders according to the following structure:

  • Northwind
    • Sales
      • Customers
      • Contacts
      • Orders
    • Inventory
      • Product Categories
      • Products

    We’re going to use our own UI, so don’t worry too much about specifying the FolderType. The layout should look something like the following (I’ve added my own images for artistic effect):

    Navigation pane with custom solution module

    As mentioned previously, the Solutions module only supports the built-in Outlook items. You’ll notice when you click on Contacts, it will show you a standard Outlook Contacts item view. In this case we want our own forms to show. For example the Orders/Invoices should show the users a form to add /edit and search orders and invoices. Of course, we can accomplish this by using Add-in Express’ Outlook Forms Manager.

    I just want to stop right here, and highlight a “gotcha” with the Solutions module. If you go into Outlook and click on the Folders view, you will see the folder structure you’ve created under your Personal Folders or root folder (Thanks Dmitry for pointing me in the right direction!). Keep this in mind when you need to access certain folders in your Solutions module. Here is an image of what I mean:
    Folders structure

    OK, let us now add a new ADX Outlook Form item to your project and a new Outlook Forms Manager component to your AddinModule designer by clicking on the ellipse (…) button in its Items property. Click the Add button and set the ExplorerLayout property to WebViewPane. Set the FormClassName to the ADX Outlook Form you’ve added and specify the FolderName property. In my example it is Personal Folders\Northwind\Sales\Orders.

    Add any controls or logic you need onto the ADX Outlook Form, then build and register your project. Open Outlook and click on the Nortwind item in your navigation pane. If everything goes well, you should see something similar to this:

    Embedded .net controls for the custom folder

    How cool is that? Fine it is just a fancy view on a folder in your Personal Folders, but none the less, it will give your add-in a more professional look.

    Thank you for reading and until next time, keep coding!

    You may also be interested in:

22 Comments

  • Ophir says:

    Is there a way to add more than one bar?
    Can the icon on the bar (the 3 cubes and a + sign) be changed?

  • Pieter van der Westhuizen says:

    Hi Ophir,

    Unfortunately, you cannot have more than one bar. As soon as you add more than one Solutions module, Outlook simply groups all the solution module folders under a single bar(navigation pane) called Solutions. Same goes for the icon, it appears we’re stuck with the 3 cubes and a plus sign :)

    Thank you for your comment.

    Kind Regards,
    Pieter

  • Erwin says:

    In outlook 2010 with Exchange, the label “Personal Folders” in the above example reads “Mailbox – Erwin”… I have to specify “Mailbox – Erwin” as FolderName. How can this work for other users? Also, the order I specify for the folders (Sales/Customers/Orders etc.) gets reordered in Outlook 2010 in no apparent order.

  • Pieter van der Westhuizen says:

    Hi Erwin,

    “Mailbox – Erwin” is your DefaultStore name. In order to get it you can use the following code:

    Outlook.NameSpace nameSpace = OutlookApp.GetNamespace(“MAPI”);
    string defaultStore = nameSpace.DefaultStore.DisplayName;

    Not sure why you’re having trouble with the sort order. Outlook sorts folders alphabetically. If you create 3 folders on the same level e.g. Sales,Customers,Orders, Outlook will sort it Customers,Orders, Sales. However, if the root folder is Sales, and you add 2 subfolders, the subfolders will be sorted Customers,Orders.

    Hope this answers your question, thank you for your comment.

    Kind regards,
    Pieter

  • Melchor says:

    Do you have a sample code for this topic. Where can i download? Thank you.

    Best regards,
    Melchor

  • Pieter van der Westhuizen says:

    Hi Melchor,

    I’ll create a sample add-in for you and let you know where to download it shortly.

    Regards,
    Pieter

  • Erwin says:

    Pieter, I now have in InitializeComponent:

    Dim nameSpace2 As Outlook.NameSpace = OutlookApp.GetNamespace(“MAPI”)
    Dim defaultStore As String = nameSpace2.DefaultStore.DisplayName

    Me.AdxOlFormsCollectionItem1.ExplorerLayout =AddinExpress.OL.ADXOlExplorerLayout.WebViewPane
    Me.AdxOlFormsCollectionItem1.FolderName = defaultStore & “\AF Database\Sales\Customers”

    Which does not work. The whole solution does not show up anymore.

  • Erwin says:

    Or putting this in AddinModule.New results in a NullReference:

    Dim oa As Outlook._Application = OutlookApp
    Dim nameSpace2 As Outlook.NameSpace = oa.GetNamespace(“MAPI”)
    Dim defaultStore As String = nameSpace2.DefaultStore.DisplayName

    Me.AdxOlFormsCollectionItem1.ExplorerLayout = AddinExpress.OL.ADXOlExplorerLayout.WebViewPane
    Me.AdxOlFormsCollectionItem1.FolderName = defaultStore & “\AF Database\Sales\Customers”
    Me.AdxOlFormsCollectionItem1.FolderNames.AddRange(New String() {defaultStore & “\AF Database\Sales\Customers”, defaultStore & “\AF Database\Sales\Customers\All Customers”, defaultStore & “\AF Database\Sales\Customers\My Customers”, defaultStore & “\AF Database\Sales\Customers\Recent Customers”})

  • Pieter van der Westhuizen says:

    Hi Erwin,

    Sorry my mistake. I should’ve mentioned you need to put the code in the AddinStartupComplete event. So in C# the code will look like this:

    private void AddinModule_AddinStartupComplete(object sender, EventArgs e)
    {
    Outlook.NameSpace nameSpace = OutlookApp.GetNamespace(“MAPI”);
    string defaultStore = nameSpace.DefaultStore.DisplayName;
    NorthwindFormsCollection.FolderName = defaultStore + @”\Northwind\Sales\Orders”;
    Marshal.ReleaseComObject(nameSpace);
    }

    Hope this helps!

    Kind regards,
    Pieter

  • Erwin says:

    That works like a charm, thanks!

  • Pieter van der Westhuizen says:

    Excellent!

    Let us know if there is anything else we can assist with.

  • Ophir says:

    Can solution folders be added/removed dynamically?

  • Pieter van der Westhuizen says:

    Hi Opher,

    Yes you can, by using the following code:

    AddinExpress.MSO.ADXOLSolutionFolder newFolder = new AddinExpress.MSO.ADXOLSolutionFolder();
    newFolder.FolderName=”Northwind”;
    newFolder.FolderType = AddinExpress.MSO.ADXOLSolutionFolderType.Notes;
    adxolSolutionFolder1.Folders.Add(newFolder);

    Hope this helps!

    Kind regards,
    Pieter

  • Jacek says:

    Hi, I try dynamically change in lFormsCollectionItem FormClassName but I don’t know how to refresh folder. Folder is refreshing only when I clicked to other folder. Do You have any idea?

  • Pieter van der Westhuizen says:

    Hi Jacek,

    Try the ApplyTo method of the FormsCollectionItem to refresh the form region. e.g:

    adxOlFormsCollectionItem1.FormClassName = “MyADXProject.NewFormRegion”;
    adxOlFormsCollectionItem1.ApplyTo(OutlookApp.ActiveExplorer());

    Good luck!

  • Jacek says:

    You are my master !!! I was trying to achieve such an effect for several hours. THX

  • Dawie says:

    Hi Pieter,

    This looks exactly like what I need.
    Have you created an example addin of this for download?
    Need to test and demo it.

    Kind regards,
    Dawie van Niekerk

  • Dawie says:

    Pieter,

    I’m using “Add-in Express 2010 for Microsoft Office and VSTO, Standard”
    adxnet-v606-b4621-vsto-std

    Will this work on it or do I have to upgrade?

    Kind regards
    Dawie

  • Pieter van der Westhuizen says:

    Hi Dawie!

    The Solutions Module will work Add-in Express 2010 for Microsoft Office and VSTO, Standard.

    All the best.
    Pieter

  • Pieter van der Westhuizen says:

    Hi Dawie,

    I have one here somewhere :) Although, it was created using Add-in Express 2010 for Office and .net.
    I’ll e-mail it to you.

    Regards,
    Pieter

  • Dawie says:

    Thanks Pieter,
    I’m createing the “Mother” folder with the designer. Then I want to be able to create the subfolders dynamically.
    My code doesn’t break and looks cool, but it doesn’t show my subfolder :-(
    I’m doing this:

    Dim newFolder As AddinExpress.VSTO.ADXOLSolutionFolder = New AddinExpress.VSTO.ADXOLSolutionFolder()
    newFolder.FolderName = defaultStore & “\Mother\Northwind”
    newFolder.FolderType = AddinExpress.VSTO.ADXOLSolutionFolderType.Notes
    AdxolSolutionFolder1.Folders.Add(newFolder)

    Dim AdxOlFormsCollectionItem3 As AddinExpress.OL.ADXOlFormsCollectionItem
    AdxOlFormsCollectionItem3 = New AddinExpress.OL.ADXOlFormsCollectionItem(Me.components)

    AdxOlFormsCollectionItem3.ExplorerLayout = AddinExpress.OL.ADXOlExplorerLayout.WebViewPane
    AdxOlFormsCollectionItem3.FolderName = defaultStore & “\Mother\Northwind”
    AdxOlFormsCollectionItem3.FormClassName = “MyVSTOAddin1.ADXOlForm1”
    AdxOlFormsCollectionItem3.UseOfficeThemeForBackground = True

    Marshal.ReleaseComObject([nameSpace])

  • Pieter van der Westhuizen says:

    Hi Dawie,

    You can add the child folders to the mother folders’ Folders collection. Do this in the AddinModule_AddinStartupComplete event :

    ‘ Root Folder
    Dim motherFolder As New ADXOLSolutionFolder()
    motherFolder.FolderName = “Mother”
    motherFolder.FolderType = ADXOLSolutionFolderType.Notes

    ‘ Child Folders
    Dim childFolder1 As New ADXOLSolutionFolder()
    childFolder1.FolderName = “Child1”
    childFolder1.FolderType = ADXOLSolutionFolderType.Notes

    Dim childFolder2 As New ADXOLSolutionFolder()
    childFolder2.FolderName = “Child2”
    childFolder2.FolderType = ADXOLSolutionFolderType.Notes

    ‘ Add Child Folders to MotherFolder
    motherFolder.Folders.Add(childFolder1)
    motherFolder.Folders.Add(childFolder2)

    ‘ Add Mother Folder to Solutions Module
    AdxolSolutionModule1.Folders.Add(motherFolder)

    Hope this helps!

Post a comment

Have any questions? Ask us right now!