如何创建仅在阅读邮件时激活的Yeoman Generator版Outlook加载项
Outlook加载项仅在阅读邮件时激活的配置修正
要让你的Outlook加载项仅在阅读邮件场景下显示功能区按钮并打开任务窗格,仅替换MessageComposeCommandSurface为MessageReadCommandSurface是不够的,还需调整配套标识并确认规则配置,具体修改如下:
1. 替换功能区扩展点及关联标识
将原撰写模式的扩展点替换为阅读模式,同时修改组ID和按钮ID(避免与旧配置冲突):
原代码片段:
<ExtensionPoint xsi:type="MessageComposeCommandSurface"> <OfficeTab id="TabDefault"> <Group id="msgComposeGroup"> <Control xsi:type="Button" id="msgComposeOpenPaneButton"> <!-- 按钮配置 --> </Control> </Group> </OfficeTab> </ExtensionPoint>
修改后:
<ExtensionPoint xsi:type="MessageReadCommandSurface"> <OfficeTab id="TabDefault"> <Group id="msgReadGroup"> <Label resid="GroupLabel"/> <Control xsi:type="Button" id="msgReadOpenPaneButton"> <Label resid="TaskpaneButton.Label"/> <Supertip> <Title resid="TaskpaneButton.Label"/> <Description resid="TaskpaneButton.Tooltip"/> </Supertip> <Icon> <bt:Image size="16" resid="Icon.16x16"/> <bt:Image size="32" resid="Icon.32x32"/> <bt:Image size="80" resid="Icon.80x80"/> </Icon> <Action xsi:type="ShowTaskpane"> <SourceLocation resid="Taskpane.Url"/> </Action> </Control> </Group> </OfficeTab> </ExtensionPoint>
2. 确认规则配置(已正确,无需修改)
你的Rule配置已经正确限定加载项仅在阅读模式的邮件中激活,保持即可:
<Rule xsi:type="RuleCollection" Mode="Or"> <Rule xsi:type="ItemIs" ItemType="Message" FormType="Read"/> </Rule>
3. 重新部署加载项
修改完成后执行以下步骤生效:
- 在Outlook中移除旧的自定义加载项
- 重新添加修改后的
manifest.xml文件 - 重启桌面版Outlook或刷新网页版页面
- 打开任意已接收邮件,检查功能区是否显示加载项按钮
修改后的完整manifest.xml核心内容
<OfficeApp> <Id>58e9bf0a-50e1-4d12-bbd7-0bc82a9a70a8</Id> <Version>1.0.0.0</Version> <ProviderName>Contoso</ProviderName> <DefaultLocale>en-US</DefaultLocale> <DisplayName DefaultValue="My Add-in"/> <Description DefaultValue="A template to get started."/> <IconUrl DefaultValue="some url"/> <HighResolutionIconUrl DefaultValue="some url"/> <SupportUrl DefaultValue="some url"/> <AppDomains> <AppDomain>some url</AppDomain> </AppDomains> <Hosts> <Host Name="Mailbox"/> </Hosts> <Requirements> <Sets> <Set Name="Mailbox" MinVersion="1.1"/> </Sets> </Requirements> <FormSettings> <Form xsi:type="ItemRead"> <DesktopSettings> <SourceLocation DefaultValue="some url"/> <RequestedHeight>250</RequestedHeight> </DesktopSettings> </Form> </FormSettings> <Permissions>ReadWriteItem</Permissions> <Rule xsi:type="RuleCollection" Mode="Or"> <Rule xsi:type="ItemIs" ItemType="Message" FormType="Read"/> </Rule> <VersionOverrides xsi:type="VersionOverridesV1_0"> <Hosts> <Host xsi:type="MailHost"/> </Hosts> <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1" xsi:type="VersionOverridesV1_1"> <Requirements> <bt:Sets DefaultMinVersion="1.3"> <bt:Set Name="Mailbox"/> </bt:Sets> </Requirements> <Hosts> <Host xsi:type="MailHost"> <DesktopFormFactor> <FunctionFile resid="Commands.Url"/> <ExtensionPoint xsi:type="MessageReadCommandSurface"> <OfficeTab id="TabDefault"> <Group id="msgReadGroup"> <Label resid="GroupLabel"/> <Control xsi:type="Button" id="msgReadOpenPaneButton"> <Label resid="TaskpaneButton.Label"/> <Supertip> <Title resid="TaskpaneButton.Label"/> <Description resid="TaskpaneButton.Tooltip"/> </Supertip> <Icon> <bt:Image size="16" resid="Icon.16x16"/> <bt:Image size="32" resid="Icon.32x32"/> <bt:Image size="80" resid="Icon.80x80"/> </Icon> <Action xsi:type="ShowTaskpane"> <SourceLocation resid="Taskpane.Url"/> </Action> </Control> </Group> </OfficeTab> </ExtensionPoint> </DesktopFormFactor> </Host> </Hosts> <Resources> <bt:Images> <bt:Image id="Icon.16x16" DefaultValue="some url"/> <bt:Image id="Icon.32x32" DefaultValue="some url"/> <bt:Image id="Icon.80x80" DefaultValue="some url"/> </bt:Images> <bt:Urls> <bt:Url id="Commands.Url" DefaultValue="some url"/> <bt:Url id="Taskpane.Url" DefaultValue="some url"/> </bt:Urls> <bt:ShortStrings> <bt:String id="GroupLabel" DefaultValue="Contoso Add-in"/> <bt:String id="TaskpaneButton.Label" DefaultValue="Show Taskpane"/> </bt:ShortStrings> <bt:LongStrings> <bt:String id="TaskpaneButton.Tooltip" DefaultValue="Opens a task pane."/> <bt:String id="ActionButton.Tooltip" DefaultValue="Perform an action when clicked."/> </bt:LongStrings> </Resources> </VersionOverrides> </VersionOverrides> </OfficeApp>
内容的提问来源于stack exchange,提问作者Bob Runstein
相关产品推荐
相关产品推荐

