如何修改manifest让Outlook Add-in无需打开邮件即可全程启用
解决方案
你当前的插件仅在打开邮件时可用,是因为manifest配置仅绑定了「邮件阅读窗体」的激活规则和扩展点,按以下步骤修改即可实现全程可用:
1. 调整最低API版本要求
全局扩展点需要更高版本的Outlook API支持,将VersionOverrides下的Requirements节点修改为:
<Requirements> <bt:Sets DefaultMinVersion="1.5"> <bt:Set Name="Mailbox" /> </bt:Sets> </Requirements>
2. 修改激活规则
原规则仅匹配邮件阅读场景,调整为支持无选中邮件的全局激活:
<Rule xsi:type="RuleCollection" Mode="Or"> <!-- 保留原有邮件阅读、编辑场景的支持 --> <Rule xsi:type="ItemIs" ItemType="Message" FormType="Read" /> <Rule xsi:type="ItemIs" ItemType="Message" FormType="Edit" /> <Rule xsi:type="ItemIs" ItemType="Appointment" FormType="Read" /> <Rule xsi:type="ItemIs" ItemType="Appointment" FormType="Edit" /> <!-- 新增无选中项时的激活规则 --> <Rule xsi:type="ItemHasKnownEntity" EntityType="None" /> </Rule>
3. 新增主界面功能区扩展点
原配置仅使用了MessageReadCommandSurface扩展点(仅在邮件阅读窗体显示),新增PrimaryCommandSurface扩展点,该扩展点会在Outlook主窗口的功能区常驻显示:
将以下代码添加到DesktopFormFactor节点下,和原有MessageReadCommandSurface节点并列:
<ExtensionPoint xsi:type="PrimaryCommandSurface"> <OfficeTab id="TabDefault"> <Group id="globalAddinGroup"> <Label resid="groupLabel" /> <Control xsi:type="Button" id="globalOpenPaneBtn"> <Label resid="paneReadButtonLabel" /> <Supertip> <Title resid="paneReadSuperTipTitle" /> <Description resid="paneReadSuperTipDescription" /> </Supertip> <Icon> <bt:Image size="16" resid="icon16" /> <bt:Image size="32" resid="icon32" /> <bt:Image size="80" resid="icon80" /> </Icon> <Action xsi:type="ShowTaskpane"> <SourceLocation resid="messageReadTaskPaneUrl" /> </Action> </Control> </Group> </OfficeTab> </ExtensionPoint>
4. 可选:调整权限
如果你的插件需要在无选中邮件时操作邮箱全局数据,可将权限从ReadWriteItem调整为ReadWriteMailbox。
修改完成后重新加载manifest即可,插件会同时在主界面功能区和邮件阅读窗体显示,无需打开邮件即可随时启用。
内容的提问来源于stack exchange,提问作者Christian Salvador
相关产品推荐
相关产品推荐

