Question

I have just purchased: http://www.add-in-express.com/outlook-regions/

The reason why I have purchased that product is because I need to show a custom form on the main view of outlook when a specific folder is selected. I have managed to do so by doing the following:

  1. Create a new Project int visual studio of type (Outlook 2010 Add-in)

  2. Once that project is created I add: enter image description here

  3. Because I want that form to show on the main folder view of mail (replace all other views) I select this option: enter image description here

  4. I click next and follow all the defaults in order to create the form.

  5. Once that form is created I add the buttons and images I need. In this example I will just add a button.

  6. when I then run outlook and select my inbox folder this is what shows up: enter image description here (In other words every time I select a folder of type olMailItem that form shows up)

  7. So now I solve my goal to display my custom form on the "main view of outlook"

Now my question is how can I show that form only on specific folders. For example I do not want to show that form when the folder "Inbox" is selected but I do want to show it when the folder "Outbox" is selected for example

Let's try to hide the form and show the default view when the button is clicked.

In order to solve that problem I have looked at: http://www.add-in-express.com/forum/read.php?FID=5&TID=4540

I have done the same steps but the form shows up again! In other words the code behind of the button looks like:

private void button1_Click(object sender, EventArgs e)
{
    // get current folder in this case its inbox the one that is selected
    MAPIFolder currentFolder = Globals.ThisAddIn.Application.ActiveExplorer().CurrentFolder;
    Globals.ThisAddIn.ADXOlForm1Item.FolderName = string.Empty;

    // clear web properties DO NOT SHOW WEB VIEW
    currentFolder.WebViewURL = string.Empty;
    currentFolder.WebViewOn = false;

    // 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 = currentFolder; // SET INBOX AGAIN
}

when I run that code the default view shows up for 1 second then it get's replaced with the form!


-------------------------------------------Edit-------------------------------------------

When I add the form region Addin Express adds a ADXOlFormsManager and a ADXOlFormsCollectionItem for the form that I created. Based on your answer I have done:

#region ADXOlForm1

    // TODO: Use the ADXOlForm1Item properties to configure the region's location, appearance and behavior.
    // See the "The UI Mechanics" chapter of the Add-in Express Developer's Guide for more information.

    ADXOlForm1Item = new ADXOlFormsCollectionItem();

    ADXOlForm1Item.FolderName = "MyCustomFolder"; // <---- ADDED THIS LINE HOPING TO SHOW THIS FORM ONLY WHEN THAT FOLDER IS SELECTED

    ADXOlForm1Item.ExplorerLayout = ADXOlExplorerLayout.WebViewPane;
    ADXOlForm1Item.ExplorerItemTypes = ADXOlExplorerItemTypes.olMailItem;
    ADXOlForm1Item.UseOfficeThemeForBackground = true;
    ADXOlForm1Item.FormClassName = typeof(ADXOlForm1).FullName;
    this.FormsManager.Items.Add(ADXOlForm1Item);
#endregion

I was hoping for that form to only show up in MyCustomFolder but it does shows up when selecting any folder of type ADXOlExplorerItemTypes.olMailItem. Perhaps I am doing something wrong....

In other words I was hoping for only the MAPIFolder MyCustomFolder folder had the properties

WebViewOn=true;
WebViewURL = "...AppData\Local\Temp\AddinExpress\ADXOlFormGeneral.html"

but as I traverse all the folders in outlook I can see that all of them have those properties even after specifying ADXOlForm1Item.FolderName = "MyCustomFolder";

Was it helpful?

Solution

Thank you for choosing Add-in Express Regions.

I understand the "main view of outlook" as the folder that Outlook shows when it is started. By default, that folder is the top-level folder of the message store. Note that this can be changed, see File | Options | Advanced | Start Outlook in this folder. I use this setting so that my Outlook shows me the Inbox at start-up.

The below is a citation from the section Context-Sensitivity of Your Outlook Form, see see the PDF file in the folder {Add-in Express}\Docs\ on your development PC:

ADXOlFormsCollectionItem provides a number of properties that allow specifying the context settings for your form. Say, you can specify item types for which your form will be shown. Note that in case of explorer, the item types that you specify are compared with the default item type of the current folder. In addition, you can specify the names of the folders for which your form will be shown in the FolderName and FolderNames properties; these properties also work for Inspector windows – in this case, the parent folder of the Outlook item is checked. An example of the folder path is "\Personal Folders\Inbox".

A special value in FolderName is an asterisk ('*'), which means "all folders". You can also specify message class(es) for which your form will be shown. Note that all context-sensitivity properties of an ADXOlFormsCollectionItem are processed using the OR Boolean operation. That is, specifying e.g. folder names extends, but not limits, the list of contexts for which your form will be shown.

That is, if you need to show the form for a given folder, specify the path to that folder in the FolderName/*FolderNames* property.


Regards from Belarus (GMT+3),

Andrei Smolin, Add-in Express Team Leader

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