An Office service that supports add-ins to interact with objects in Office client applications.
Hi @Ashish Pal
Based on your description, this does not look like a failure in your onMessageSend handler itself. The key point is that your add-in completes successfully, all Office.js calls return AsyncResultStatus.Succeeded, and the failure happens only after event.completed({`` ``allowEvent:`` ``true`` ``}), during Outlook’s native cloud-attachment finalization flow.
From the information available, the most reasonable interpretation is that the add-in may be triggering or exposing a timing/state issue in New Outlook’s send pipeline, but the actual error appears to occur in Outlook’s own attachment or cloud-link handling path. In particular, the odbsharelightspeed.js authToken failure and the attachments.office.net CORS error are not errors returned by your add-in APIs.
Please refer the following workarounds:
- Immediate technical workarounds (try in this order)
-Prefer body.prependAsync (header) + body.appendAsync (footer) instead of full get + set
-Use item.saveAsync() before calling event.completed
-Minimize HTML changes (avoid rewriting large parts of the body)
-Fall back to subject prefix only when cloud attachments are present
Example of safer body modification pattern:
function onMessageSendHandler(event) {
Office.context.mailbox.item.getAttachmentsAsync((result) => {
const hasCloudAttachment = result.value?.some(att =>
att.attachmentType === "cloud" || att.isInline === false && att.name?.includes(".sharepoint")
);
if (hasCloudAttachment) {
// Safer path – only touch subject or use prepend/append carefully
// or skip classification for now
event.completed({ allowEvent: true });
return;
}
// Normal path with prepend/append
Office.context.mailbox.item.body.prependAsync(
"<div>...classification header...</div>",
{ coercionType: Office.CoercionType.Html },
() => {
Office.context.mailbox.item.body.appendAsync(
"<div>...classification footer...</div>",
{ coercionType: Office.CoercionType.Html },
() => event.completed({ allowEvent: true })
);
}
);
});
}
- Longer-term / architectural options
- Move classification to Sensitivity Labels (Purview) if the requirement is compliance-related — these integrate much better with the send pipeline and handle cloud attachments correctly.
- Use a SoftBlock Smart Alert that shows a dialog and lets the user confirm, instead of silently modifying the body on every send.
- For high-impact classification scenarios, consider a combination of OnNewMessageCompose + OnMessageFromChanged + a final SoftBlock check.
I hope this information help.
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.