3
votes

Is it possible to create a custom folder type using VSTO for Outlook 2007? (i.e. a new folder type similar to olFolderContacts and so on)

Ideally what I would like to do is have a folder which, when selected, would create a new form region in the main Outlook window (where the Inbox and the Preview Pane are) and display a WPF User Control.

Thanks

Something like:

enter image description here

I found that image meanwhile trying to solve this question at: http://www.add-in-express.com/add-in-net/outlook-regions-basics.php

3

3 Answers

0
votes

The closest thing I have able to do is:

  • Create folder on outlook (I named it login):

  • Then right click and set its home page:

    enter image description here

  • then when I select that folder or on code behind I can select it my outlook looks like:

    enter image description here

It will be nice if I can do the same but with a wpf form or custom region. Now I have to use websockets or other mechanism to comunicate events with that control.

0
votes

Since Outlook uses Internet Explorer as its browser, you get native support for SilverLight. Is there a chance you could embed your contents in a SilverLight webpage and then set that as your folder's home page? WPF and SL share a lot of common ground, so maybe this is a solution for you.

0
votes

Found the solution. The only caveat is that I need to purchase Advanced Outlook regions for VSTO and it cost me 100 dollars. If you purchase that product this is how you do it:

1. Create a new project on vistual studio of type (Outlook 2010 Add-in) I named my project OutlookAddIn1

2. Add a new item to the project (Product that I needed to purchase) enter image description here

3. When you select that item a wizard shows up select the following options: enter image description here

4. Follow all the defaults until the wizard finishes (click next, next etc. finish)

5. There you have a windows forms. In order to place WPF content you will need to add a ElementHost controls. There are a log of tutorials on how to host a wpf usercontrol on windows forms. To keep this answer not that long I will not show how.

6. For demo of this answer I will just place a button on that form: enter image description here

7. with the press of that button I will hide that form and show the deffault view of the folder. So here is the code behind of that button:

    private void button1_Click(object sender, EventArgs e)
    {
        // disable the form that id does not show up
        Globals.ThisAddIn.ADXOlForm1Item.Enabled = false;

        // get the current selected folder
        var thisFOlder = Globals.ThisAddIn.Application.ActiveExplorer().CurrentFolder;

        // remove the webview pane in order to show the main folder view instead
        thisFOlder.WebViewOn = false;
        thisFOlder.WebViewURL = string.Empty;

        // RESET FOLDER BY SELECTING A DIFFERENT ONE THEN THE SAME ONE
        NameSpace nameSpace = Globals.ThisAddIn.Application.GetNamespace("MAPI");
        MAPIFolder outboxFolder = nameSpace.GetDefaultFolder(OlDefaultFolders.olFolderOutbox);
        Globals.ThisAddIn.Application.ActiveExplorer().CurrentFolder = outboxFolder; // CHANGE FOLDER TO A DIFFERNT ONE
        System.Windows.Forms.Application.DoEvents();
        Globals.ThisAddIn.Application.ActiveExplorer().CurrentFolder = thisFOlder; // SET INBOX AGAIN

        // remeember to release objects
        Marshal.ReleaseComObject(nameSpace);
        Marshal.ReleaseComObject(outboxFolder);
        Marshal.ReleaseComObject(thisFOlder);

        this.Close();
    }

8. When I then run that project note when I see when selecting any folder of type Mail: enter image description here

9. If I press that button I will then show the default view of the folder I had selected

The only probelm that I have now is that the view shows for every folder of type MailItem. You could select a different folder type on the first wizzard something that is not that common like Jurnal. Then on code behind you can select a jurnal folder for that form to show up.