0
votes

I have created a form using form region which takes user input using VSTO outlook C#. The button which opens this form is located near Message button as shown in the image :

Button service desk showed near message

I want this button in my custom ribbon (eg. MY DESK -> Service Desk) that I already developed

Is it possible to move this button to the ribbon that I want?

2
why down vote ?? I think lot of people facing this issue - Abhijeet

2 Answers

0
votes

You can create a custom ribbon UI in your add-in where you can repeat the built-in controls by specifying their idMso. VSTO provides two possible ways for customizing the Fluent UI (aka Ribbon UI):

To find control IDs you may download Office 2016 Help Files: Office Fluent User Interface Control Identifiers. Also, you may check them in Outlook by navigating to the Customize ribbon page and looking at the popping out hints.

Also, you may place a custom ribbon control anywhere and call the following code to display your custom UI:

myitem.GetInspector.SetCurrentFormPage("Namespace.FormRegionClass")

The name used in SetCurrentFormPage should be full class name for your custom region.

0
votes

Thank you @Eugene, your answer gave me hint to solve my problem

First I open new mail with code :

Application oApp = Globals.ThisAddIn.Application;
        NameSpace oNs = oApp.GetNamespace("MAPI");
        MAPIFolder oInbox = oNs.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
        Items oItems = oInbox.Items;
        MailItem oForm = oItems.Add("IPM.Note");
        oForm.Display(false);

And then instead of "GetInspector" I used "ActiveInspector()" and set it with my class name

"oApp.ActiveInspector().SetCurrentFormPage("NameSpace.ClassName");"

The complete code on button click:

private void btnOpenMailForm_Click(object sender, RibbonControlEventArgs e)
    {
        Application oApp = Globals.ThisAddIn.Application;
        NameSpace oNs = oApp.GetNamespace("MAPI");
        MAPIFolder oInbox = oNs.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
        Items oItems = oInbox.Items;
        MailItem oForm = oItems.Add("IPM.Note");
        oForm.Display(false);  
        oApp.ActiveInspector().SetCurrentFormPage("NameSpace.ClassName");
    }

This opens my custom outlook form from the button click of ribbon button.