C# 中的 Outlook 插件 - 如何在新邮件中添加按钮/组(签名旁边)

发布于 2024-08-23 16:08:21 字数 1611 浏览 3 评论 0原文

我在理解 Outlook 术语(CommandBarPopup、CommandBarButton 等)时遇到一些困难,例如 Outlook 中的内容,因此请耐心等待。

我想创建几件事:

  1. 我想在签名/添加附件旁边的新邮件上创建新组(或只是按钮,但我读到不可能将按钮添加到功能区中的现有组)消息功能区。它的工作方式必须与签名的工作方式相同,因此当您按下它时,它会显示几个选项。我如何创建它?

  2. 我想覆盖“新”按钮(您可以在其中选择要发送新邮件、预约或执行其他操作),以便当您在主窗口中按新邮件旁边的向下箭头时按钮您可以选择我要添加的选项之一?这可能吗?我该怎么做?

  3. 我有一些在主窗口中添加菜单的代码

    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:

  1. 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?

  2. 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?

  3. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凶凌 2024-08-30 16:08:21
  1. 这是不可能的,因为 OOM 不会公开这种类型的按钮:(即使 MS 使用它。您可以隐藏一个按钮组,然后通过添加标准命令来创建您自己的“类似”组,这有点给您相同的东西。

编辑:XML隐藏标准操作组..使用其可见属性及其idMso

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load" loadImage="GetImage">
  <ribbon>
    <tabs>
      <tab idMso="TabReadMessage">
        <group idMso="GroupActions" visible="false">   
        </group>

        <group id="newactionsgroup" label="Actions" insertAfterMso="GroupActions">
          <button idMso="Delete" size="large"/>
          <button id="MoveToFolder" imageMso="MoveToFolder" size="large" label="Move To Folder" onAction="myMoveToFolder" />
          <button idMso="CreateMailRule" size="large"/>
          <menu idMso="OtherActionsMenu" size="large"/>
        </group>
     </tab>
    </tabs>
  </ribbon>
</customUI>
  1. 根本不可能,尽管您可以再次隐藏现有按钮并使用良好位置表单创建类似的内容

3.创建您的buttonOne作为CommandBarPopup

  1. Is not possible in that the OOM does not expose this type of button :( even though MS use it. You can though hide a Button group and then create your own "similar" group by adding standard Commands, kinda giving you the same thing.

EDIT: XML to hide standard Action group .. using its visible property and its idMso

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load" loadImage="GetImage">
  <ribbon>
    <tabs>
      <tab idMso="TabReadMessage">
        <group idMso="GroupActions" visible="false">   
        </group>

        <group id="newactionsgroup" label="Actions" insertAfterMso="GroupActions">
          <button idMso="Delete" size="large"/>
          <button id="MoveToFolder" imageMso="MoveToFolder" size="large" label="Move To Folder" onAction="myMoveToFolder" />
          <button idMso="CreateMailRule" size="large"/>
          <menu idMso="OtherActionsMenu" size="large"/>
        </group>
     </tab>
    </tabs>
  </ribbon>
</customUI>
  1. Not possible at all though you can again hide the existing button and create something similar with a well position form !

3.Create your buttonOne as a CommandBarPopup

流年已逝 2024-08-30 16:08:21

我不知道这是否是您在第二点中寻找的内容,但我设法使用以下代码将自定义菜单项添加到“新建”按钮下拉列表中:

  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);
        }

    }

I don't know if this is what you are looking for in your second point, but I managed to add a custom menu item to the "New" button dropdown with the following code:

  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);
        }

    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文