OfficeDev/office-js

My launchEvent doesn´t trigger when is OnNewMessageCompose in Outlook

Closed this issue · 6 comments

Provide required information needed to triage your issue

I am trying to get a signature applied when any kind of mail is created and I have created a launchevent with OnNewMessageCompose but it works everywhere except Outlook version 16.0.7019 or later. And I can't get any log or anything.

Your Environment

  • Platform [PC desktop, Mac, iOS, Office on the web]:Desktop
  • Host [Excel, Word, PowerPoint, etc.]: Outlook
  • Operating System: Windows

Expected behavior

My idea is that users tran configure their signatures can create the mail and have the signature applied correctly without having to reopen the taskpane but the event is not triggered.

Current behavior

All other actions work correctly, the only thing that doesn't work is the launchevent.

Useful logs

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<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">
    <Id>d9220785-54b5-446c-8e96-f3bff5d351cb</Id>
    <Version>1.0.0.0</Version>
    <ProviderName>StampyMail</ProviderName>
    <DefaultLocale>en-US</DefaultLocale>
    <DisplayName DefaultValue="StampyMail for Outlook">
        <Override Locale="es-es" Value="StampyMail para Outlook" />
    </DisplayName>
    <Description DefaultValue="An add-in to handle StampyMail signatures">
        <Override Locale="es-es" Value="Un complemento para gestionar firmas de StampyMail"/>
    </Description>
    <IconUrl DefaultValue="https://localhost:3000/assets/icon-64.png" />
    <HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/icon-128.png" />
    <SupportUrl DefaultValue="https://stampymail.com/contacto/" /> <!-- Support URL -->
    <AppDomains>
        <AppDomain>https://stampymail.com</AppDomain> <!-- App Domain -->
    </AppDomains>
    <Hosts>
        <Host Name="Mailbox" />
    </Hosts>
    <Requirements>
        <Sets>
            <Set Name="Mailbox"
                 MinVersion="1.13" />
        </Sets>
    </Requirements>
    <FormSettings>
        <Form xsi:type="ItemRead">
            <DesktopSettings>
                <SourceLocation DefaultValue="https://localhost:3000/taskpane.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">
        <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1"
                          xsi:type="VersionOverridesV1_1">
            <Requirements>
                <bt:Sets>
                    <bt:Set Name="Mailbox" MinVersion="1.13"/>
                </bt:Sets>
            </Requirements>
            <Hosts>
                <Host xsi:type="MailHost">
                    <Runtimes>
                        <Runtime resid="Taskpane.Url">
                            <Override type="javascript"
                                      resid="JSRuntime.Url" />
                        </Runtime>
                        <Runtime resid="Commands.Url">

                        </Runtime>
                    </Runtimes>
                    <DesktopFormFactor>
                        <FunctionFile resid="Taskpane.Url" />
                        <!-- Message Compose -->
                        <ExtensionPoint xsi:type="MessageComposeCommandSurface">
                            <OfficeTab id="TabDefault">
                                <Group id="msgComposeCmdGroup">
                                    <Label resid="GroupLabel" />
                                    <Control xsi:type="Button"
                                             id="TaskpaneButton">
                                        <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>
                        <!-- Configures event-based activation. -->
                        <ExtensionPoint xsi:type="LaunchEvent">
                            <LaunchEvents>
                                <LaunchEvent Type="OnNewMessageCompose"
                                             FunctionName="onNewMessageComposeHandler" />
                            </LaunchEvents>
                            <SourceLocation resid="Taskpane.Url" />
                        </ExtensionPoint>
                        <!-- End Message Compose -->
                    </DesktopFormFactor>
                    <MobileFormFactor>
                        <ExtensionPoint xsi:type="LaunchEvent">
                            <LaunchEvents>
                                <LaunchEvent Type="OnNewMessageCompose" FunctionName="onNewMessageComposeHandler" />
                            </LaunchEvents>
                            <SourceLocation resid="Commands.Url" />
                        </ExtensionPoint>
                    </MobileFormFactor>
                </Host>
            </Hosts>
            <Resources>
                <bt:Images>
                    <bt:Image id="Icon.16x16"
                              DefaultValue="https://localhost:3000/assets/icon-16.png" />
                    <bt:Image id="Icon.32x32"
                              DefaultValue="https://localhost:3000/assets/icon-32.png" />
                    <bt:Image id="Icon.80x80"
                              DefaultValue="https://localhost:3000/assets/icon-80.png" />
                </bt:Images>
                <bt:Urls>
                    <bt:Url id="Taskpane.Url"
                            DefaultValue="https://localhost:3000/taskpane.html" />
                    <bt:Url id="JSRuntime.Url"
                            DefaultValue="https://localhost:3000/desktop-launchevent.js" />
                    <bt:Url id="Commands.Url"
                            DefaultValue="https://localhost:3000/commands.html"/>
                </bt:Urls>
                <bt:ShortStrings>
                    <bt:String id="GroupLabel"
                               DefaultValue="StampyMail for Outlook" />
                    <bt:String id="TaskpaneButton.Label"
                               DefaultValue="StampyMail for Outlook" />
                    <bt:String id="residTaskPaneButtonName"
                               DefaultValue="StampyMail for Outlook" />
                </bt:ShortStrings>
                <bt:LongStrings>
                    <bt:String id="TaskpaneButton.Tooltip"
                               DefaultValue="Start to work with StampyMail signatures." />
                </bt:LongStrings>
            </Resources>
        </VersionOverrides>
    </VersionOverrides>
</OfficeApp>

And this is the desktop-launchevent.js:

/*  global console, Office, loadSignature */

// The OnNewMessageCompose event handler that adds a signature to a new message.
async function onNewMessageComposeHandler(event) {
  await loadSignature({ event }).catch((error) => {
    console.log("Error loading signature: ");
    console.log(error);
  });
}

// IMPORTANT: To ensure your add-in is supported in the Outlook client
// on Windows, remember to map the event handler name specified in the
// manifest's LaunchEvent element to its JavaScript counterpart.
const officePlatform = Office.context?.platform;
if (officePlatform === Office.PlatformType.PC || officePlatform == null) {
  Office.actions.associate("onNewMessageComposeHandler", onNewMessageComposeHandler);
}

The function of loadSignature works because it´s used in other classes but here it doesn´t work

Something new?? Because I see that I´am not the only one with the launchEvent problems

LaunchEvents in "Old" Outlook, run in a JSRuntime instead of a WebView. It also only supports ECMAScript 2016.

https://learn.microsoft.com/en-us/office/dev/add-ins/outlook/troubleshoot-event-based-and-spam-reporting-add-ins

I believe your calls to await calls are not allowed. You can also turn on runtime logging to maybe get some more insights here.

I tried everything and the event doesn´t lunch, I don´t what else to do.

What's the current code in your launchEvent.js file?

This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!

This issue has been closed due to inactivity. Please comment if you still need assistance and we'll re-open the issue.