Outlook Web 插件不执行命名函数
Outlook Web Add-in not executing named function
按照几个地方的文档[主要是在 Microsoft 此处:https://docs.microsoft.com/en-us/javascript/api/office/office.addincommands.event?view=office-js and here: https://docs.microsoft.com/en-us/outlook/add-ins/add-in-commands-for-outlook 但也来自各种搜索等] 我无法获得 UI Less Functions 在 Outlook Desktop 或 Outlook Web 中工作访问。
两者似乎都在调用函数文件,因为我可以对其进行测试并成功地看到 Office.Initilize 函数的输出。但是我根本无法调用实际命名的函数。
我看过很多例子,但找不到其他人抱怨它不起作用,所以一定是做错了什么,但我找不到错误:
清单:
<?xml version="1.0" encoding="UTF-8"?>
<OfficeApp
xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0"
xsi:type="MailApp">
<!-- Begin Basic Settings: Add-in metadata, used for all versions of Office unless override provided. -->
<!-- IMPORTANT! Id must be unique for your add-in, if you reuse this manifest ensure that you change this id to a new GUID. -->
<Id>e540c7ff-41e8-47a2-b2ae-7e3cae3336bc</Id>
<!--Version. Updates from the store only get triggered if there is a version change. -->
<Version>1.0.0.2</Version>
<ProviderName>[Provider name]</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<!-- The display name of your add-in. Used on the store and various places of the Office UI such as the add-ins dialog. -->
<DisplayName DefaultValue="FunctionExecuteTest" />
<Description DefaultValue="[Outlook Add-in description]"/>
<!-- Icon for your add-in. Used on installation screens and the add-ins dialog. -->
<IconUrl DefaultValue="https://localhost:3000/assets/icon-32.png" />
<HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/hi-res-icon.png"/>
<!--If you plan to submit this add-in to the Office Store, uncomment the SupportUrl element below-->
<!--<SupportUrl DefaultValue="[Insert the URL of a page that provides support information for the app]" />-->
<!-- Domains that will be allowed when navigating. For example, if you use ShowTaskpane and then have an href link, navigation will only be allowed if the domain is on this list. -->
<AppDomains>
<AppDomain>AppDomain1</AppDomain>
<AppDomain>AppDomain2</AppDomain>
<AppDomain>AppDomain3</AppDomain>
</AppDomains>
<!--End Basic Settings. -->
<Hosts>
<Host Name="Mailbox" />
</Hosts>
<Requirements>
<Sets>
<Set Name="Mailbox" MinVersion="1.3" />
</Sets>
</Requirements>
<FormSettings>
<Form xsi:type="ItemRead">
<DesktopSettings>
<SourceLocation DefaultValue="https://localhost:3000/index.html"/>
<RequestedHeight>250</RequestedHeight>
</DesktopSettings>
</Form>
</FormSettings>
<Permissions>ReadWriteItem</Permissions>
<Rule xsi:type="RuleCollection" Mode="Or">
<Rule xsi:type="ItemIs" ItemType="Message" FormType="Read" />
</Rule>
<DisableEntityHighlighting>false</DisableEntityHighlighting>
<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
<Requirements>
<bt:Sets DefaultMinVersion="1.3">
<bt:Set Name="Mailbox" />
</bt:Sets>
</Requirements>
<Hosts>
<Host xsi:type="MailHost">
<DesktopFormFactor>
<!-- Location of the Functions that UI-less buttons can trigger (ExecuteFunction Actions). -->
<FunctionFile resid="functionFile" />
<!-- Message Read -->
<ExtensionPoint xsi:type="MessageReadCommandSurface">
<!-- Use the default tab of the ExtensionPoint or create your own with <CustomTab id="myTab"> -->
<OfficeTab id="TabDefault">
<!-- Up to 6 Groups added per Tab -->
<Group id="msgReadGroup">
<Label resid="groupLabel" />
<!-- Function (UI-less) button -->
<Control xsi:type="Button" id="eventTestButton">
<Label resid="funcComposeButtonLabel" />
<Supertip>
<Title resid="funcComposeSuperTipTitle" />
<Description resid="funcComposeSuperTipDescription" />
</Supertip>
<Icon>
<bt:Image size="16" resid="icon16" />
<bt:Image size="32" resid="icon32" />
<bt:Image size="80" resid="icon80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>testEventObject</FunctionName>
</Action>
</Control>
<!-- Go to http://aka.ms/ButtonCommands to learn how to add more Controls: ExecuteFunction and Menu -->
</Group>
</OfficeTab>
</ExtensionPoint>
<!-- Go to http://aka.ms/ExtensionPointsCommands to learn how to add more Extension Points: MessageRead, AppointmentOrganizer, AppointmentAttendee -->
</DesktopFormFactor>
</Host>
</Hosts>
<Resources>
<bt:Images>
<bt:Image id="icon16" DefaultValue="https://localhost:3000/assets/icon-16.png"/>
<bt:Image id="icon32" DefaultValue="https://localhost:3000/assets/icon-32.png"/>
<bt:Image id="icon80" DefaultValue="https://localhost:3000/assets/icon-80.png"/>
</bt:Images>
<bt:Urls>
<bt:Url id="functionFile" DefaultValue="https://localhost:3000/function-file/function-file.html"/>
<bt:Url id="messageReadTaskPaneUrl" DefaultValue="https://localhost:3000/index.html"/>
</bt:Urls>
<bt:ShortStrings>
<bt:String id="groupLabel" DefaultValue="Test Add-in Group"/>
<bt:String id="funcComposeButtonLabel" DefaultValue="Test Tab"/>
<bt:String id="funcComposeSuperTipTitle" DefaultValue="Execute the test that's been setup"/>
</bt:ShortStrings>
<bt:LongStrings>
<bt:String id="funcComposeSuperTipDescription" DefaultValue="Does something, something expected..."/>
</bt:LongStrings>
</Resources>
</VersionOverrides>
</OfficeApp>
函数-file.js:
// The initialize function must be run each time a new page is loaded
Office.initialize = reason => {
console.log('Office init...' + reason);
};
// Add any ui-less function here
function testEventObject(event) {
var buttonId = event.source.id;
console.log('testEventObject() called, buttonID: ' + buttonId);
event.complete();
}
我实际得到的是:
Browser Console Log
希望我缺少一些简单的东西!
根据 FunctionFile element 上的文档,event
应该调用方法 completed()
。您发布的函数在调用 event.complete();
时存在语法错误。这需要解决。
functionFile
元素指向“https://localhost:3000/function-file/function-file.html”,但描述中的脚本快照是针对 function-file.js
的。请检查您是否正确地将 JS 文件包含到您的 HTML 文件中。例如,如果您对资源使用绝对 URI,则它必须以 https (SSL) 开头。另外,尽量在这个 JS 文件中只保留你需要的函数,以避免任何其他 JS 错误。
按照几个地方的文档[主要是在 Microsoft 此处:https://docs.microsoft.com/en-us/javascript/api/office/office.addincommands.event?view=office-js and here: https://docs.microsoft.com/en-us/outlook/add-ins/add-in-commands-for-outlook 但也来自各种搜索等] 我无法获得 UI Less Functions 在 Outlook Desktop 或 Outlook Web 中工作访问。
两者似乎都在调用函数文件,因为我可以对其进行测试并成功地看到 Office.Initilize 函数的输出。但是我根本无法调用实际命名的函数。
我看过很多例子,但找不到其他人抱怨它不起作用,所以一定是做错了什么,但我找不到错误:
清单:
<?xml version="1.0" encoding="UTF-8"?>
<OfficeApp
xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0"
xsi:type="MailApp">
<!-- Begin Basic Settings: Add-in metadata, used for all versions of Office unless override provided. -->
<!-- IMPORTANT! Id must be unique for your add-in, if you reuse this manifest ensure that you change this id to a new GUID. -->
<Id>e540c7ff-41e8-47a2-b2ae-7e3cae3336bc</Id>
<!--Version. Updates from the store only get triggered if there is a version change. -->
<Version>1.0.0.2</Version>
<ProviderName>[Provider name]</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<!-- The display name of your add-in. Used on the store and various places of the Office UI such as the add-ins dialog. -->
<DisplayName DefaultValue="FunctionExecuteTest" />
<Description DefaultValue="[Outlook Add-in description]"/>
<!-- Icon for your add-in. Used on installation screens and the add-ins dialog. -->
<IconUrl DefaultValue="https://localhost:3000/assets/icon-32.png" />
<HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/hi-res-icon.png"/>
<!--If you plan to submit this add-in to the Office Store, uncomment the SupportUrl element below-->
<!--<SupportUrl DefaultValue="[Insert the URL of a page that provides support information for the app]" />-->
<!-- Domains that will be allowed when navigating. For example, if you use ShowTaskpane and then have an href link, navigation will only be allowed if the domain is on this list. -->
<AppDomains>
<AppDomain>AppDomain1</AppDomain>
<AppDomain>AppDomain2</AppDomain>
<AppDomain>AppDomain3</AppDomain>
</AppDomains>
<!--End Basic Settings. -->
<Hosts>
<Host Name="Mailbox" />
</Hosts>
<Requirements>
<Sets>
<Set Name="Mailbox" MinVersion="1.3" />
</Sets>
</Requirements>
<FormSettings>
<Form xsi:type="ItemRead">
<DesktopSettings>
<SourceLocation DefaultValue="https://localhost:3000/index.html"/>
<RequestedHeight>250</RequestedHeight>
</DesktopSettings>
</Form>
</FormSettings>
<Permissions>ReadWriteItem</Permissions>
<Rule xsi:type="RuleCollection" Mode="Or">
<Rule xsi:type="ItemIs" ItemType="Message" FormType="Read" />
</Rule>
<DisableEntityHighlighting>false</DisableEntityHighlighting>
<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
<Requirements>
<bt:Sets DefaultMinVersion="1.3">
<bt:Set Name="Mailbox" />
</bt:Sets>
</Requirements>
<Hosts>
<Host xsi:type="MailHost">
<DesktopFormFactor>
<!-- Location of the Functions that UI-less buttons can trigger (ExecuteFunction Actions). -->
<FunctionFile resid="functionFile" />
<!-- Message Read -->
<ExtensionPoint xsi:type="MessageReadCommandSurface">
<!-- Use the default tab of the ExtensionPoint or create your own with <CustomTab id="myTab"> -->
<OfficeTab id="TabDefault">
<!-- Up to 6 Groups added per Tab -->
<Group id="msgReadGroup">
<Label resid="groupLabel" />
<!-- Function (UI-less) button -->
<Control xsi:type="Button" id="eventTestButton">
<Label resid="funcComposeButtonLabel" />
<Supertip>
<Title resid="funcComposeSuperTipTitle" />
<Description resid="funcComposeSuperTipDescription" />
</Supertip>
<Icon>
<bt:Image size="16" resid="icon16" />
<bt:Image size="32" resid="icon32" />
<bt:Image size="80" resid="icon80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>testEventObject</FunctionName>
</Action>
</Control>
<!-- Go to http://aka.ms/ButtonCommands to learn how to add more Controls: ExecuteFunction and Menu -->
</Group>
</OfficeTab>
</ExtensionPoint>
<!-- Go to http://aka.ms/ExtensionPointsCommands to learn how to add more Extension Points: MessageRead, AppointmentOrganizer, AppointmentAttendee -->
</DesktopFormFactor>
</Host>
</Hosts>
<Resources>
<bt:Images>
<bt:Image id="icon16" DefaultValue="https://localhost:3000/assets/icon-16.png"/>
<bt:Image id="icon32" DefaultValue="https://localhost:3000/assets/icon-32.png"/>
<bt:Image id="icon80" DefaultValue="https://localhost:3000/assets/icon-80.png"/>
</bt:Images>
<bt:Urls>
<bt:Url id="functionFile" DefaultValue="https://localhost:3000/function-file/function-file.html"/>
<bt:Url id="messageReadTaskPaneUrl" DefaultValue="https://localhost:3000/index.html"/>
</bt:Urls>
<bt:ShortStrings>
<bt:String id="groupLabel" DefaultValue="Test Add-in Group"/>
<bt:String id="funcComposeButtonLabel" DefaultValue="Test Tab"/>
<bt:String id="funcComposeSuperTipTitle" DefaultValue="Execute the test that's been setup"/>
</bt:ShortStrings>
<bt:LongStrings>
<bt:String id="funcComposeSuperTipDescription" DefaultValue="Does something, something expected..."/>
</bt:LongStrings>
</Resources>
</VersionOverrides>
</OfficeApp>
函数-file.js:
// The initialize function must be run each time a new page is loaded
Office.initialize = reason => {
console.log('Office init...' + reason);
};
// Add any ui-less function here
function testEventObject(event) {
var buttonId = event.source.id;
console.log('testEventObject() called, buttonID: ' + buttonId);
event.complete();
}
我实际得到的是:
Browser Console Log
希望我缺少一些简单的东西!
根据 FunctionFile element 上的文档,event
应该调用方法 completed()
。您发布的函数在调用 event.complete();
时存在语法错误。这需要解决。
functionFile
元素指向“https://localhost:3000/function-file/function-file.html”,但描述中的脚本快照是针对 function-file.js
的。请检查您是否正确地将 JS 文件包含到您的 HTML 文件中。例如,如果您对资源使用绝对 URI,则它必须以 https (SSL) 开头。另外,尽量在这个 JS 文件中只保留你需要的函数,以避免任何其他 JS 错误。