0

I'm currently struggeling to get my onMessageSendHandler to work on Outlook Web and Mac. When the user sends a message, I want the user to have the option to open taskpane instead of sending the mail. This works on Classic Outlook windows.

Classic Outlook windows working example

On Mac/Web I get this error:

Outlook web error

This is my onMessageSendHandler function:

 async function onMessageSendHandler(event) {
  event.completed({
        allowEvent: false,
        errorMessage: "Do you want to open taskpane?",
        cancelLabel: "Open taskpane",
        commandId: "msgComposeOpenPaneButton",
        sendModeOverride: Office.MailboxEnums.SendModeOverride.PromptUser
      });
  }

Office.actions.associate("onMessageSendHandler", onMessageSendHandler);

My LaunchEvent part in Manifest.xml:

  <ExtensionPoint xsi:type="LaunchEvent">
            <LaunchEvents>
              <LaunchEvent Type="OnNewMessageCompose" FunctionName="onNewMessageComposeHandler"/>
              <LaunchEvent Type="OnNewAppointmentOrganizer" FunctionName="onNewAppointmentComposeHandler"/>
              <LaunchEvent Type="OnMessageSend" FunctionName="onMessageSendHandler"/>
            </LaunchEvents>
            <SourceLocation resid="WebViewRuntime.Url"/>
          </ExtensionPoint>
New contributor
RobinSta is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

1 Answer 1

0

How to make it work everywhere

  1. Keep your manifest on a lower requirement set (e.g. 1.12)
    That ensures the add-in still loads on clients that don’t yet support 1.14, but you can optionally use 1.14 APIs when they’re available.

  2. Gate the 1.14-only options at runtime

    async function onMessageSendHandler(event) {
      const supports114 = Office.context.requirements.isSetSupported("Mailbox", "1.14");
    
      if (supports114) {
        // Full Smart Alerts experience: custom button + task pane + PromptUser
        event.completed({
          allowEvent: false,
          errorMessage: "Do you want to open taskpane?",
          cancelLabel: "Open taskpane",
          commandId: "msgComposeOpenPaneButton",
          sendModeOverride: Office.MailboxEnums.SendModeOverride.PromptUser
        });
      } else {
        // Fallback for Web/Mac (or any client < 1.14)
        // You *cannot* wire the Smart Alerts dialog to open the task pane here.
        // Just block send and tell the user to open the add-in from the ribbon.
        event.completed({
          allowEvent: false,
          errorMessage:
            "To proceed, open the add-in from the ribbon, complete the required steps, then send again."
        });
      }
    }
    
    Office.actions.associate("onMessageSendHandler", onMessageSendHandler);
    
    
  3. Ensure the commandId matches your task-pane button ID

    In your <MessageComposeCommandSurface> (or equivalent) you should have something like:

    <Control xsi:type="Button" id="msgComposeOpenPaneButton">
      ...
    </Control>
    
    

    That ID must exactly match the commandId you pass in event.completed.


The important limitation

On clients that don’t support Mailbox 1.14 yet, there’s no way to have the Smart Alerts dialog directly open the task pane. The best you can do is:

  • Use Smart Alerts to block sending and show instructions, and

  • Have the user click your task-pane button in the ribbon manually.

Once your Web/Mac clients catch up to 1.14, the “full” path (with cancelLabel + commandId + sendModeOverride) will start working there too without further changes.

Sign up to request clarification or add additional context in comments.

3 Comments

This answer seems to presuppose that 1.14 is not supported on Web or Mac where the OG is getting the error. But according to this table, it is: Outlook client support
“supported by the platform” ≠ “definitely present in the OP’s current environment”. you’re absolutely right that the general docs say OWA and Mac are 1.14-capable, so the blanket “they don’t support 1.14” statement was wrong. The real issue is “this particular environment / packaging isn’t delivering the 1.14 Smart Alerts behavior correctly”.
Yes, but your answer assumes that the REASON the 1.14 behavior isn't be delivered is because OG is working on platforms that don't support it. But the OG is not on platforms that don't support it. Your answer is not relevant.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.