How to troubleshoot 'onMessageSend' event not triggering in Outlook Addin?
We have been working on new Outlook Addin using new Microsoft framework. We faced the challenge when trying to implement event for onMessageSend. The problem is that validateSubjectAndCC does not get invoked, so we don't see text in console log.
We used samples from here:
https://learn.microsoft.com/en-us/office/dev/add-ins/outlook/outlook-on-send-addins?tabs=modern
We are using add-in only Manifest file:
<ExtensionPoint xsi:type="Events">
<Event Type="onMessageSend" FunctionExecution="synchronous" FunctionName="validateSubjectAndCC" />
</ExtensionPoint>
We updated commands.js file :
Office.onReady(() => {
// If needed, Office.js is ready to be called.
Office.actions.associate("onMessageSend", validateSubjectAndCC);
});
// Event handler for ItemSend event
export function validateSubjectAndCC(event) {
console.log("onItemSend event triggered");
// Simulate some async operation if needed
// For demo purposes, allow the send to continue
mailboxItem.cc.setAsync(['******@test.com'], { asyncContext: event });
event.completed({ allowEvent: false });
}
Steps for reproducing issue:
- Open Outlook on web
- Click to create new email
- Open my addin in taskpan
- Enter To, Subject and Body
- Click Send
- I expected to see in Development Console log "onMessageSend event triggered"
Similarly, we would like to implement event onAppointmentSend. Can you please provide example and required permission for onAppointmentSend to work?
Sample manifest file: