C# 单击outlook项目(如邮件、联系人、日历和任务)的事件处理

C# 单击outlook项目(如邮件、联系人、日历和任务)的事件处理,c#,visual-studio-2008,outlook,outlook-addin,C#,Visual Studio 2008,Outlook,Outlook Addin,我想实现outlook加载项以访问outlook项目的详细信息,如邮件、日历、任务和联系人 我已经创建了示例插件,并将许多自定义项添加到上下文菜单中。但我现在需要的是,如果我单击outlook联系人,则上下文菜单中只有与联系人相关的自定义项(例如联系人姓名),所有其他项要么禁用,要么从上下文菜单中删除(例如事件名称) 示例代码如下所示: public void PacktMenuItem_ItemContextMenuDisplay(Microsoft.Office.Core.CommandBa

我想实现outlook加载项以访问outlook项目的详细信息,如邮件、日历、任务和联系人

我已经创建了示例插件,并将许多自定义项添加到上下文菜单中。但我现在需要的是,如果我单击outlook联系人,则上下文菜单中只有与联系人相关的自定义项(例如联系人姓名),所有其他项要么禁用,要么从上下文菜单中删除(例如事件名称)

示例代码如下所示:

public void PacktMenuItem_ItemContextMenuDisplay(Microsoft.Office.Core.CommandBar PacktCommandBar, Microsoft.Office.Interop.Outlook.Selection Selection) { // Commadbarpopup control to context menu item Office.CommandBarPopup callBarPopUp = (Office.CommandBarPopup)PacktCommandBar.Controls.Add(Office.MsoControlType.msoControlPopup, Type.Missing, "Custom Menu Item 1", PacktCommandBar.Controls.Count + 1, Type.Missing); // Set the tag value for the menu callBarPopUp.Tag = "PacktCustomMenuItem1"; // Caption for the context menu item callBarPopUp.Caption = "custom items"; // Set it to visible callBarPopUp.Visible = true; //item 1 Office.CommandBarButton callButton2 = (Office.CommandBarButton)callBarPopUp.Controls.Add(1, missing, missing, missing, true); callButton2.Caption = "Contact Name"; callButton2.Click += new Office._CommandBarButtonEvents_ClickEventHandler(Callxx2); //item 2 Office.CommandBarButton callButton3 = (Office.CommandBarButton)callBarPopUp.Controls.Add(1, missing, missing, missing, true); callButton3.Caption = "Event Name"; callButton3.Click += new Office._CommandBarButtonEvents_ClickEventHandler(Callxx3); } public void PacktMenuItem_ItemContextMenuDisplay(Microsoft.Office.Core.CommandBar PacktCommandBar、Microsoft.Office.Interop.Outlook.Selection) { //Commadbarpopup控件到上下文菜单项 Office.CommandBarPopup callBarPopUp=(Office.CommandBarPopup)PacktCommandBar.Controls.Add(Office.MsoControlType.msoControlPopup,Type.Missing,“自定义菜单项1”,PacktCommandBar.Controls.Count+1,Type.Missing); //设置菜单的标记值 callBarPopUp.Tag=“PacktCustomMenuItem1”; //上下文菜单项的标题 callBarPopUp.Caption=“自定义项”; //将其设置为可见 callBarPopUp.Visible=true; //项目1 Office.CommandBarButton callButton2=(Office.CommandBarButton)callBarPopUp.Controls.Add(1,缺失,缺失,缺失,为真); callButton2.Caption=“联系人姓名”; callButton2.Click+=新建办公室。_commandBarButtoneEvents_ClickEventHandler(Callxx2); //项目2 Office.CommandBarButton callButton3=(Office.CommandBarButton)callBarPopUp.Controls.Add(1,缺失,缺失,缺失,为真); callButton3.Caption=“事件名称”; callButton3.Click+=新建办公室。_CommandBarButtonEvents_ClickEventHandler(Callxx3); }
请引导

终于找到了一个好帖子,它帮助我解决了我的疑问

感谢微软……)