Outlook Add-in: How to communicate from OnMessageSend event to an Angular task pane?

Krystian Dawid 0 Reputation points
2025-07-22T18:12:10.0866667+00:00

Hi everyone,

I'm developing an Outlook add-in using Angular and the Office.js library. I'm facing a challenge with communication between the OnMessageSend event and my main application running in the task pane.


My Goal I want to execute logic (e.g., call a function in an Angular component) that is running in my task pane as soon as the user clicks the "Send" button in Outlook.


In my manifest.xml, I've registered the event-based add-in for the send event as follows:

XML

<ExtensionPoint xsi:type="LaunchEvent">
  <LaunchEvents>
    <LaunchEvent Type="OnMessageSend" FunctionName="onItemSend" SendMode="PromptUser"/>
  </LaunchEvents>
  <SourceLocation resid="OfficeFunctions.Url"/>
</ExtensionPoint>

The onItemSend handler function in my JavaScript file is being called correctly. From there, I can successfully display Smart Alerts and cancel the email send if needed.


The Problem The onItemSend function runs in its own JavaScript runtime, which is separate from the task pane's runtime. Because of this, I have no direct access to my Angular components or services in the task pane.


What I've tried

SessionStorage: Communicating via the browser's SessionStorage didn't work, because the different runtimes don't share a common storage space.

CustomProperties: I'm currently using Office.context.mailbox.item.customProperties as a workaround. I can set a property in the onItemSend handler, which my Angular app in the task pane then reads. However, this feels like a clumsy solution because my Angular app would have to actively poll the properties rather than reacting to a direct event.


My Question What is the best-practice way to trigger an action in my open Angular task pane from the onItemSend event handler?

Are there any established patterns or examples for this that are better than using CustomProperties?

Thanks in advance for your help and any ideas!

Microsoft 365 and Office | Development | Office JavaScript API
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Dora-T 3,225 Reputation points Microsoft External Staff Moderator
    2025-07-23T04:27:55.02+00:00

    Hi @Krystian Dawid

    Welcome to Microsoft Q&A Forum. 

    I understand you're trying to trigger logic in your Angular task pane when the OnMessageSend event is fired, and I can see why that would be a useful and intuitive interaction in your add-in. 

    Based on the documentation and resources I’ve been able to access, there doesn’t appear to be a supported or official way to communicate directly between the OnMessageSend event handler and a running task pane, as they operate in separate runtimes. As you've noted, using CustomProperties can be a possible workaround, though I understand it may feel a bit clunky given the need for polling from the task pane side. I’m really sorry for the inconvenience this limitation might cause.  

    I know this might not be the outcome you were hoping for, but I do hope that future updates to the Office.js platform will introduce more flexible and seamless ways to support this kind of communication. 

    Thank you for your patience and for sharing your scenario in such detail. If you have any other concerns, feel free to reach out again.


    If the answer is partially helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".     

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.