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

标签 c# outlook outlook-addin

我在理解 Outlook 术语(CommandBarPopup、CommandBarButton 等)时遇到一些问题,例如 Outlook 中的内容,所以请耐心等待。

我想创建一些东西:

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

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

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

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

我想在 buttonOne 下添加子菜单,这样当我按下它时,新的子菜单就会打开。我该如何实现?

最佳答案

  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

关于c# - C# 中的 Outlook 插件 - 如何在新邮件中添加按钮/组(在签名旁边),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2375051/

相关文章:

c# - 在 Android 上按下/选择任何文本时弹出菜单

html - 如何在不影响背景图像的情况下向 <td> 添加填充?

javascript - Outlook Rest Api — 获取特定时区的日历 View (REST)

multithreading - 如何在 Outlook 2007 加载项中高效运行后台任务?

c# - 从 javascript 获取带有渲染的 html 的网页源代码

C# 唯一索引通用集合

c# - 全局异常处理 VS Try catch everywhere

HTML 签名仅在 Outlook 中调整部分图像的大小

c# - 使用 C# 在 Outlook 中禁用回复或转发

outlook - 如何在Outlook COM/VSTO和Office JS加载项之间共享用户漫游设置