Question

I was reading through the Office/Outlook 2013 Developer Reference for quite a while now and I didn't find any information on embedding a full screen WPF window or similar.

My goal is that when a user changes to a specific folder within in Outlook, the main content page should be replaced with a fully customized UI. It is no problem to open a separate WPF window, but I would like to embed the UI as full screen within the Outlook window itself.

I know of the concept of form regions (replace-all) but it didn't really work as expected.

Assume there is a Replace-All form region with a factory message class IPM.Test.MainRegion. I thought that intercepting the folder switch event can allow me to invoke the region that is supposed to display the main region in a replacing fashion:

void explorer_BeforeFolderSwitch(object NewFolder, ref bool Cancel)
{
  Outlook.Folder target = NewFolder as Outlook.Folder;

  if (target.Name == "Test")
  {
    Outlook.NameSpace ns = this.Application.GetNamespace("MAPI");
    Outlook.MAPIFolder mapi = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);

    Outlook.MailItem item = mapi.Items.Add("IPM.Test.MainRegion") as Outlook.MailItem;
    item.Display(false); //no modal window - but still opens a modal

    Cancel = true; //don't actually switch the folder to surpress default view.
  }
}

The problem is that this code in fact opens a new mail window (although the parameter of Display is false) and it shows nothing of the form designed within the VS Region Designer.

Is there anything I am missing here? The Office Developer Reference doesn't really say anything about replace-all regions (only for non-custom Message Classes, in which case it is trivial).

Do you have any suggestions?

UPDATE

So, there seems to be now way show form regions within the main view folder. Form regions are always associated with a item type they are registered for (Calendar, Task, Mail...). Hence, Form Regions are not the way to do it. It is either not possible to completely replace the main window or there is another way.

Was it helpful?

Solution

Set MAPIFolder.WebViewOn property to true and MAPIFolder.WebViewURL to a url (can be a local file) that contains the HTML that you want to show. That HTML page can embed any controls that you are trying to display.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top