【发布时间】:2023-04-05 00:49:01
【问题描述】:
我对开发 Outlook 插件比较陌生,并且在开发 On-send 插件时遇到了问题。
我正在尝试从我的 on-send 加载项中执行 ajax 调用,如下所示:
$.ajax({
url: "https://XXXXXXX.dev:9999/createMeeting",
data: JSON.stringify(result),
contentType: 'application/json',
type: 'POST',
dataType: 'json',
error: function(xhr, status, error) {
console.log("ERRROR", error)
}
}).done(function(data) {
console.log("DONE ", data)
});
我的清单如下所示:
<?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" xsi:type="MailApp">
<AppDomains>
<AppDomain>DOMAIN1</AppDomain>
<AppDomain>DOMAIN2</AppDomain>
</AppDomains>
<Id>XXXXXXXX-1a52-42a0-96bf-100d801a4ef7</Id>
<Version>1.0</Version>
<ProviderName>Contoso</ProviderName>
<DefaultLocale>en-us</DefaultLocale>
<DisplayName DefaultValue="Contoso Subject and CC Checker" />
<Description DefaultValue="Contoso Subject and CC Checker" />
<Requirements>
<Sets DefaultMinVersion="1.1">
<Set Name="Mailbox" />
</Sets>
</Requirements>
<FormSettings>
<Form xsi:type="ItemEdit">
<DesktopSettings>
<SourceLocation DefaultValue="https://XXXXXXXX.dev:3001/index.html" />
</DesktopSettings>
</Form>
</FormSettings>
<Permissions>ReadWriteMailbox</Permissions>
<Rule xsi:type="RuleCollection" Mode="Or">
<Rule xsi:type="ItemIs" ItemType="Message" FormType="Edit" />
<Rule xsi:type="ItemIs" ItemType="Appointment" FormType="Edit" />
</Rule>
<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
<!-- On Send requires VersionOverridesV1_1 -->
<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1" xsi:type="VersionOverridesV1_1">
<Description resid="residAppDescription" />
<Requirements>
<bt:Sets DefaultMinVersion="1.3">
<bt:Set Name="Mailbox" />
</bt:Sets>
</Requirements>
<Hosts>
<Host xsi:type="MailHost">
<DesktopFormFactor>
<!-- The functionfile and function name to call on message send. -->
<!-- In this particular case the function validateSubjectAndCC will be called within the JavaScript code referenced in residUILessFunctionFileUrl. -->
<FunctionFile resid="residUILessFunctionFileUrl" />
<ExtensionPoint xsi:type="Events">
<Event Type="ItemSend" FunctionExecution="synchronous" FunctionName="validateSubjectAndCC" />
</ExtensionPoint>
</DesktopFormFactor>
</Host>
</Hosts>
<Resources>
<bt:Urls>
<!-- The JavaScript code is hosted on a secure and trusted web server. -->
<bt:Url id="residUILessFunctionFileUrl" DefaultValue="https://XXXXXXXX.dev:3001/index.html"></bt:Url>
</bt:Urls>
</Resources>
</VersionOverrides>
</VersionOverrides>
</OfficeApp>
但是当我尝试添加插件时,我不断收到此错误
This app can't be installed.
The manifest file doesn't conform to the schema definition.
The element 'OfficeApp' in namespace 'http://schemas.microsoft.com/office/appforoffice/1.1' has invalid child element 'AppDomains' in namespace 'http://schemas.microsoft.com/office/appforoffice/1.1'.
List of possible elements expected: 'Id' in namespace 'http://schemas.microsoft.com/office/appforoffice/1.1'...
The element 'OfficeApp' in namespace 'http://schemas.microsoft.com/office/appforoffice/1.1' has invalid child element 'AppDomains' in namespace 'http://schemas.microsoft.com/office/appforoffice/1.1'.
List of possible elements expected: 'Id' in namespace 'http://schemas.microsoft.com/office/appforoffice/1.1'.
根据docs,AppDomains 元素必须是OfficeApp 元素的子元素。 难道我做错了什么?? 提前致谢!
编辑: 这发生在 Outlook OWA (web) 和 Windows 应用程序上。尚未在其他平台上验证。
【问题讨论】:
-
您应该从模板清单开始,然后从那里开始。在您链接的那篇文章的顶部是您可以开始使用的清单。您已经缺少该模板中的一些必需元素(IconUrl、SupportUrl、Hosts 等)。该模板由于某种原因没有 AppDomains,但我认为您在文档中将其放置得太高了。在我们的清单中,AppDomains 位于 SupportUrl 之后和 Hosts 之前。还要确保域名完全符合协议,即以 https 开头。
-
另外,您能说说您遇到的是哪个平台吗?它是在 windows(outlook 客户端)、outlook web、mac 还是任何其他移动平台上?
-
@OutlookAdd-insTeam-MSFT 。这发生在 Outlook OWA (web) 和 Windows 应用程序上。尚未在其他平台上验证。我被困在这很糟糕! :(
-
我从您发布的 repo 链接中获取了该示例,并在说明之后和要求之前添加了 AppDomain。它确实产生了积极的影响,因为没有 AppDomains,它似乎在 CORS 预检请求中死掉了。请注意,这里有一个潜在的时间问题,一旦您返回 mailboxItem.notificationMessages.addAsync 或 asyncResult.asyncContext.completed 或两者,似乎应用程序将结束/关闭,因此您必须构造代码以不设置消息或完成状态,直到您的 Ajax 调用被返回/处理。
标签: javascript outlook-addin office-addins outlook-web-addins