Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding Outlook 2013 mailitem contextmenu. VS 2012 C#

Hi i want to add a new button to outlook 2013 mailitem contextmenu. I use VS 2012 C#.

I seached internet but cant find a way to do this, im upgrading an Outlook 2010 addin which modified the contextmenu.

like image 795
Jes Gudiksen Avatar asked Mar 15 '13 11:03

Jes Gudiksen


1 Answers

In visual studio on project select add new item. Choose Ribbon(XML).

add following to XML file:

<contextMenus>
    <contextMenu idMso="ContextMenuMailItem">
     <menu id="ArcIT" label="ArcIT">
       <button id="MyContextMenuMailItem"
           label="ContextMenuMailItem"
           onAction="OnMyButtonClick"/>
     </menu >
   </contextMenu>
  </contextMenus>

in ribbon.cs class add following method

public void OnMyButtonClick(Office.IRibbonControl control)
    {


        if (control.Context is Outlook.Selection)
        {
            Outlook.Selection sel = control.Context as Outlook.Selection;
            Outlook.MailItem mail = sel[1];
            MessageBox.Show(mail.Subject.ToString());

        }
    }

method has to be public. This method shows a box with subject from the mail u right clicked.

like image 144
Jes Gudiksen Avatar answered Oct 11 '22 01:10

Jes Gudiksen