Outlook Addin in C # - How to add a button / group in New Mail (next to signatures)

I'm having trouble understanding Outlook terms (CommandBarPopup, CommandBarButton, etc.), like what is in Outlook, so please be patient.

I would like to create a couple of things:

  • I would like to create a new group (or just a button, but I can’t add a button to an existing group in the feed) in the new mail next to the signatures / add attachments in the message feed. It should work just like Signature, so when you click on it, it displays several options. How can I create it?

  • I would like to redefine the "NEW" button (where you can choose whether you want to send new mail, make an appointment or do other things), so when you are in the main window, when you click the down arrow next to the new button, you can choose one of options that I will add? Is it possible? How to do it?

  • I have a code that adds a menu to the Main window

    private void AddMenuBar() { try { //Define the existent Menu Bar menuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar; //Define the new Menu Bar into the old menu bar newMenuBar = (Office.CommandBarPopup) menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, false); //If I dont find the newMenuBar, I add it if (newMenuBar != null) { newMenuBar.Caption = "Test"; newMenuBar.Tag = menuTag; buttonOne = (Office.CommandBarButton) newMenuBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true); buttonOne.Style = Office.MsoButtonStyle.msoButtonIconAndCaption; buttonOne.Caption = "Test Button"; //This is the Icon near the Text buttonOne.FaceId = 610; buttonOne.Tag = "c123"; //Insert Here the Button1.Click event buttonOne.Click += new Office._CommandBarButtonEvents_ClickEventHandler(ButtonOneClick); newMenuBar.Visible = true; } } catch (Exception ex) { //This MessageBox is visible if there is an error System.Windows.Forms.MessageBox.Show("Error: " + ex.Message.ToString(), "Error Message Box", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } 

I would like to add a submenu to buttonOne, so when I click it, new submenus open. How do I achieve this?

+4
source share
2 answers
  • It is impossible for OOM to not show this type of button :( even if MS uses it. You can hide the Button group and then create your own β€œsimilar” group by adding standard commands, the same item.

EDIT: XML to hide the standard action group .. using its visible property and its idMso

 <?xml version="1.0" encoding="UTF-8"?> <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load" loadImage="GetImage"> <ribbon> <tabs> <tab idMso="TabReadMessage"> <group idMso="GroupActions" visible="false"> </group> <group id="newactionsgroup" label="Actions" insertAfterMso="GroupActions"> <button idMso="Delete" size="large"/> <button id="MoveToFolder" imageMso="MoveToFolder" size="large" label="Move To Folder" onAction="myMoveToFolder" /> <button idMso="CreateMailRule" size="large"/> <menu idMso="OtherActionsMenu" size="large"/> </group> </tab> </tabs> </ribbon> </customUI> 
  1. Impossible at all, although you can hide the existing button again and create something similar to the shape of the well position!

3.Create your One button as CommandBarPopup

+3
source

I don’t know if this is what you are looking for in second place, but I managed to add a custom menu item to the drop-down menu of the "Create" button with the following code:

  private void AddButtonToNewDropdown() { Office.CommandBar commandBar = this.Application.ActiveExplorer().CommandBars["Standard"]; Office.CommandBarControl ctl = commandBar.Controls["&New"]; if (ctl is Office.CommandBarPopup) { Office.CommandBarPopup newpopup = (Office.CommandBarPopup)ctl; commandBarButton = (Office.CommandBarButton)newpopup.Controls.Add(1, missing, missing, missing, true); commandBarButton.Caption = "My custom button"; commandBarButton.Click += new Office._CommandBarButtonEvents_ClickEventHandler(ButtonClick); } } 
+1
source

Source: https://habr.com/ru/post/1303052/


All Articles