Building custom solutions that extend, automate, and integrate Microsoft 365 apps.
Developing Outlook Addin: Function addHandlerAsync has invalid parameters
Hello,
I am developing an Outlook addin in Javascript using React. I have problems detecting text selection in an email when composing it and when the addin is enabled in the task pane.
My code looks the following:
Office.context.mailbox.item.addHandlerAsync(
Office.EventType.ItemChanged,
function(eventArgs) {
if (eventArgs.itemType === Office.MailboxEnums.ItemType.Message) {
if (eventArgs.item.getSelectedDataAsync) {
eventArgs.item.getSelectedDataAsync(
Office.CoercionType.Text,
function(result) {
if (result.status === Office.AsyncResultStatus.Succeeded) {
var selectedText = result.value;
}
}
);
}
}
}
I get an error which says" Function addHandlerAsync has invalid parameters". Not sure what is invalid here?
However I tried a lot to get rid of this error and changed
Office.context.mailbox.item.addHandlerAsync
into (removed the item)
Office.context.mailbox.addHandlerAsync
and I did not get the error anymore but it is not working and not recognizing any text selection. I also think the second option is the right way to continue for recognising events in an email when compose.
I also tried to give the permissions in the manifest file but I am not sure what else to change or if that problem is related to that.
I would appreciate some help
Thanks
Microsoft 365 and Office | Development | Other
Outlook | Windows | Classic Outlook for Windows | For business
Using classic Outlook for Windows in business environments