问题
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