Outlook ItemSend event as a standard Office.EventType usable in Taskpane code
Right now, if we want to perform some actions when the user clicks the button Send in Outlook, we need to create ExtensionPoint event in the manifest
<Hosts> <Host xsi:type="MailHost"> <DesktopFormFactor> <FunctionFile resid="Taskpane.Url"/> <ExtensionPoint xsi:type="AppointmentOrganizerCommandSurface"> <!--some stuff--> </ExtensionPoint> <ExtensionPoint xsi:type="AppointmentAttendeeCommandSurface"> <!--some stuff--> </ExtensionPoint> <ExtensionPoint xsi:type="Events"> <Event Type="ItemSend" FunctionExecution="synchronous" FunctionName="validateBody" /> </ExtensionPoint> </DesktopFormFactor> </Host> </Hosts>
Problem is, this creates a totally new instance for the event with no communication with the Taskpane code; furthermore the ItemSend event is also triggered when the Taskpane is closed, and there's no way to tell in the ItemSend function if the Taskpane is opened or closed.
Thus I propose a much simpler and practical solution which would be to have the ItemSend event as a common https://docs.microsoft.com/en-us/javascript/api/office/office.eventtype?view=common-js-preview and then simply using addHandlerAsync.
Then in the Taskpane JS code we could detect when the user clicked the ItemSend button and then perform some actions.
1 Comment
- Nick20351Copper Contributor
Good luck. MS devs have become the new overly opinionated Apple devs.
You can still achieve what you want by setting session data in the taskpane every second and then checking it in a Smart Alert to see if more than a second has elapsed. This will tell if you if the Taskpane is open.
By design you need to duplicate any code you wish to execute in the Smart Alert. And just to save you a lot of headache, the Smart Alert runs with the same modern javascript engine as Outlook.com, but the Outlook native version uses some stripped down JS engine that doesn't support any modern JS features and will be a huge pain to develop against.
From Taskpane:
Office.context.mailbox.item?.sessionData.setAsync("taskPaneTimestamp", new Date().toISOString());