adding Outlook 2013 mailitem contextmenu. VS 2012 C#

梦想的初衷 提交于 2019-12-21 17:12:05

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/15431286/adding-outlook-2013-mailitem-contextmenu-vs-2012-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!