C# 中的 Outlook 插件 - 如何在新邮件中添加按钮/组(签名旁边)
我在理解 Outlook 术语(CommandBarPopup、CommandBarButton 等)时遇到一些困难,例如 Outlook 中的内容,因此请耐心等待。
我想创建几件事:
我想在签名/添加附件旁边的新邮件上创建新组(或只是按钮,但我读到不可能将按钮添加到功能区中的现有组)消息功能区。它的工作方式必须与签名的工作方式相同,因此当您按下它时,它会显示几个选项。我如何创建它?
我想覆盖“新”按钮(您可以在其中选择要发送新邮件、预约或执行其他操作),以便当您在主窗口中按新邮件旁边的向下箭头时按钮您可以选择我要添加的选项之一?这可能吗?我该怎么做?
我有一些在主窗口中添加菜单的代码
private void AddMenuBar() { 尝试 { //定义现有的菜单栏 menuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar; //将新的菜单栏定义到旧的菜单栏中 newMenuBar = (Office.CommandBarPopup) menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, 缺失, 缺失, 缺失, false); //如果我没有找到newMenuBar,我添加它 if (newMenuBar != null) { newMenuBar.Caption = "测试"; newMenuBar.Tag = menuTag; buttonOne = (Office.CommandBarButton) newMenuBar.Controls.Add(Office.MsoControlType.msoControlButton, 缺失, 缺失, 1, true); ButtonOne.Style = Office.MsoButtonStyle.msoButtonIconAndCaption; buttonOne.Caption = "测试按钮"; //这是文本附近的图标 按钮One.FaceId = 610; 按钮One.Tag =“c123”; //在这里插入Button1.Click事件 buttonOne.Click += new Office._CommandBarButtonEvents_ClickEventHandler(ButtonOneClick); newMenuBar.Visible = true; } } catch (异常前) { //如果有错误,这个MessageBox是可见的 System.Windows.Forms.MessageBox.Show("错误:" + ex.Message.ToString(), "错误消息框", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
我想在buttonOne下添加子菜单,这样当我按下它时,就会打开新的子菜单。我该如何实现这一目标?
I'm having some trouble understanding Outlook terms (CommandBarPopup, CommandBarButton etc) like what is what in Outlook so please be patient.
I would like to create couple of things:
I would like to create new group (or just button but i read it's not possible to add a button to an existing group in ribbon) on new mail next to Signature/Add attachment in Message Ribbon. It would have to work the same way Signature works so when you press it it display couple of options. How can i create it?
I would like to override a button "NEW" (where you can choose that you want to send new mail, make appointment or do other things) so that when you are in Main Window when you press the down arrow next to new button you could choose one of options i will add? Is this possible? How do I do it?
I have some code that adds a menu in Main Window
private void AddMenuBar() { try { //Define the existent Menu Bar menuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar; //Define the new Menu Bar into the old menu bar newMenuBar = (Office.CommandBarPopup) menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, false); //If I dont find the newMenuBar, I add it if (newMenuBar != null) { newMenuBar.Caption = "Test"; newMenuBar.Tag = menuTag; buttonOne = (Office.CommandBarButton) newMenuBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true); buttonOne.Style = Office.MsoButtonStyle.msoButtonIconAndCaption; buttonOne.Caption = "Test Button"; //This is the Icon near the Text buttonOne.FaceId = 610; buttonOne.Tag = "c123"; //Insert Here the Button1.Click event buttonOne.Click += new Office._CommandBarButtonEvents_ClickEventHandler(ButtonOneClick); newMenuBar.Visible = true; } } catch (Exception ex) { //This MessageBox is visible if there is an error System.Windows.Forms.MessageBox.Show("Error: " + ex.Message.ToString(), "Error Message Box", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
I would like to add submenu under the buttonOne so when i press it new submenus open up. How do I achieve that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
评论(2)
我不知道这是否是您在第二点中寻找的内容,但我设法使用以下代码将自定义菜单项添加到“新建”按钮下拉列表中:
private void AddButtonToNewDropdown()
{
Office.CommandBar commandBar = this.Application.ActiveExplorer().CommandBars["Standard"];
Office.CommandBarControl ctl = commandBar.Controls["&New"];
if (ctl is Office.CommandBarPopup)
{
Office.CommandBarPopup newpopup = (Office.CommandBarPopup)ctl;
commandBarButton = (Office.CommandBarButton)newpopup.Controls.Add(1, missing, missing, missing, true);
commandBarButton.Caption = "My custom button";
commandBarButton.Click += new Office._CommandBarButtonEvents_ClickEventHandler(ButtonClick);
}
}
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
编辑:XML隐藏标准操作组..使用其可见属性及其idMso
3.创建您的buttonOne作为CommandBarPopup
EDIT: XML to hide standard Action group .. using its visible property and its idMso
3.Create your buttonOne as a CommandBarPopup