如何使用 VSTO 在主页选项卡上添加自定义按钮

How to add a custom button on the Home Tab using VSTO

我正在创建 outlook VSTO 以将自定义按钮添加到主页功能区。我已将代码添加到 ribbon.xml:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
  <ribbon>
    <tabs>
      <tab idMso="TabHome">
    <group id="Phishing" label="Phishing">
      <button id="Phishing_Email" label="Phishing_Email" size="large" />
    </group>
  </tab>
</tabs>
</ribbon>
</customUI>

并将代码添加到 ThisAddin.cs 但是在测试代码时按钮没有出现而且我没有收到任何错误。

有人可以帮忙吗?

首先,我注意到您为功能区使用了旧的命名空间 XML:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">

相反,您需要指定以下一项:

   <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">

然后确保主机应用程序加载了加载项并调用了 GetCustomUI 方法。请注意,您必须 return 此功能区 XML 标记仅供检查器 windows 使用。

Walkthrough: Create a custom tab by using Ribbon XML 描述了创建自定义 Fluent UI 所需的所有步骤。