在我的VSTO Outlook插件中,我正在尝试放置一个按钮,在右键单击文件夹时会显示出来。在我的启动函数中,我有以下代码:
Outlook.Application myApp = new Outlook.ApplicationClass();
myApp.FolderContextMenuDisplay += new ApplicationEvents_11_FolderContextMenuDisplayEventHandler(myApp_FolderContextMenuDisplay);
然后我有一个处理程序...
void myApp_FolderContextMenuDisplay(CommandBar commandBar, MAPIFolder Folder)
{
var contextButton = commandBar.Controls.Add(MsoControlType.msoControlButton, missing, missing, missing, true) as CommandBarButton;
contextButton.Visible = true;
contextButton.Caption = "some caption...";
contextButton.Click += new _CommandBarButtonEvents_ClickEventHandler(contextButton_Click);
}
最后是处理点击的事件处理程序...
void contextButton_Click(CommandBarButton Ctrl, ref bool CancelDefault)
{
//stuff here
}
我的问题是如何将
MAPIFolder Folder
从myApp_FolderContextMenuDisplay
发送到contextButton_Click
?(如果有其他方法可以实现,我也很乐意听取建议)