Hello,
I am currently working on a Outlook add-in that applies the signature at the end of the body when the user starts composing an email or replies to another email.
Currently I have two javascript files, one is the taskpane.js and the other is the command.js file. Both of these make an API call to retrieve the current user's signatures (in HTML format).
The taskpane.js file is supposed to run when the user explicitly opens the application from the ribbon. The command.js file should run in the background.
Inside my manifest.xml I have the following values (frontend and backend values are placeholders):
1. Runtimes
<Runtimes>
<Runtime resid="WebViewRuntime.Url">
<Override type="javascript" resid="JSRuntime.Url" />
</Runtime>
</Runtimes>
2. AppDomains
<AppDomains>
<AppDomain>__FRONTEND_BASE_URL__</AppDomain>
<AppDomain>__BACKEND_API_URL__</AppDomain>
</AppDomains>
3. LaunchEvent ExtensionPoint (Desktop)
<ExtensionPoint xsi:type="LaunchEvent">
<LaunchEvents>
<LaunchEvent Type="OnNewMessageCompose" FunctionName="onNewMessageCompose" />
<LaunchEvent Type="OnMessageRecipientsChanged"
FunctionName="onMessageRecipientsChanged" />
</LaunchEvents>
<SourceLocation resid="WebViewRuntime.Url" />
</ExtensionPoint>
4. Relevant Resource URLs
<bt:Url id="WebViewRuntime.Url"
DefaultValue="__FRONTEND_BASE_URL__/commands.html" />
<bt:Url id="JSRuntime.Url"
DefaultValue="__FRONTEND_BASE_URL__/commands.js" />
5. Permissions
<Permissions>ReadWriteItem</Permissions>
On Outlook Web, both the taskpane and the command scripts work fine, but on Outlook Classic only the taskpane can execute network calls.
Initially, when using the fetch() function, this error was returned: The request does not meet the requirements for Same-Origin policy or Simple Cross-Origin resource sharing.
So I proceeded to setup my .well-know/microsoft-officeaddins-allowed.json as this:
{
"allowed": [
"__FRONTEND_BASE_URL__/command.js"
]
}
When monitoring network requests with Fiddle, I saw that Outlook classic successfully requested and downloaded the microsoft-officeaddins-allowed.json file.
After restarting Outlook classic, the command.js file gave me this error: A connection with the server could not be established.
Also, I noticed (by watching Fiddle logs) that the requests made by the command.js never leaved the machine.
I'm wondering if there is a way to give the background script network access in order to execute API calls.
Thank!