bondo's avatar
bondo
Copper Contributor
Nov 27, 2026
Status:
New

Outlook add-ins: event after a message is sent, with the sent item's internetMessageId and itemId

This generalises the idea "Retrieve RFC message ID after sending the email" (4410862), which asks for the Message-ID of a mail sent with sendAsync. This idea asks for a launch event after *every* send, however the user sends, that gives the sent item's IDs and lets the add-in read the sent copy.

 

Problem

An add-in that archives mail to a document or project system needs to file the user's sent replies, not only received mail. To do that it must know which item in Sent Items is the message just sent:

- its internetMessageId, to match the thread and avoid duplicates;

- its itemId, to read it, for example with getAsFileAsync.

 

Office.js has no event after send. The event-based activation docs list OnMessageSend, which runs before the message leaves, and state that the add-in stops when the user sends the item. In compose mode there is no internetMessageId (only inReplyTo, Mailbox 1.14) and no getAsFileAsync.

 

Current workarounds and why they fail

- OnMessageSend / Smart Alerts: runs before send; the final message and its IDs do not exist yet, and code after event.completed is not guaranteed to run.

- item.sendAsync (Mailbox 1.15) from our own UI: it has a callback, but the docs say code on its success path isn't guaranteed to run, the result carries no ID of the sent item, and it only covers sends the add-in starts itself (office-js #5528, idea 4410862).

- Mark the draft with a custom property, then find it later in Sent Items: needs the user to open the sent copy with the add-in, and the docs are unclear (the Sent Items note vs the "Platform behavior in messages" table) on whether custom properties survive on the Sent Items copy. Even then, the internetMessageId "may not be available yet on recently sent items" (Office.MessageRead docs).

- Microsoft Graph change notifications on Sent Items: they need an Entra app registration with Mail.Read, tenant consent and a server-side subscription per mailbox, and they do not work on Exchange on-premises. They can match the sent item to what the add-in decided in compose in practice only through custom properties (internet headers would also reach the recipients), and those may not survive on Sent Items (see above).

 

Proposed API (sketch)

A new launch event, for example OnMessageSent (unified manifest: messageSent), raised once the message has been submitted and its copy is saved in Sent Items:

 

```js

function onMessageSent(event) {

// event.sentItem: { itemId, internetMessageId, conversationId, inReplyTo }

// event.sessionData or the custom properties set during compose, so the add-in can see what it decided before send

// Office.context.mailbox.item: the Sent Items copy in read mode, so getAsFileAsync works on it

event.completed();

}

```

 

This is a separate launch event on the sent item, not a sendAsync callback, so the compose window and its sandbox need not survive the send. That is the reason given in office-js #5528. No UI is needed in this handler; a short background run, as other launch events have, is enough. If the event cannot wait for the Sent Items copy, it would already help to return the internetMessageId alone after submission, together with a way to read that item later (getAsFileAsync by itemId or by internetMessageId).

 

Secondary and optional, separate from the event: expose the References header in compose mode, next to inReplyTo, so an add-in can recognise the thread of a reply before it is sent.

 

Clients

The clients that support OnMessageSend today: Outlook on the web, new Outlook on Windows, classic Outlook on Windows and the new Outlook on Mac (Mac via the add-in only manifest).

 

Related

- Idea "Retrieve RFC message ID after sending the email" (the narrower ask): https://techcommunity.microsoft.com/idea/microsoft365developerplatform/retrieve-rfc-message-id-after-sending-the-email/4410862

- office-js #5528, "Retrieve RFC message ID after sending the email": https://github.com/OfficeDev/office-js/issues/5528

- Idea "Smart alerts: Add handling for Send anyway and don't send buttons": https://techcommunity.microsoft.com/idea/microsoft365developerplatform/smart-alerts-add-handling-for-send-anyway-and-dont-send-buttons/4414459

- Event-based activation, supported events: https://learn.microsoft.com/en-us/office/dev/add-ins/develop/event-based-activation

- Microsoft Q&A, "Why the add-in no longer has access to the sent item for further processing or modification". The accepted answer says this is expected: the legacy on-send (ItemSend) context ends after send, and Smart Alerts (OnMessageSend) also runs at send time only. https://learn.microsoft.com/en-us/answers/questions/5859763/why-the-add-in-no-longer-has-access-to-the-sent-it

- Idea "Outlook ItemSend event as a standard Office.EventType usable in Taskpane code" (a pre-send event for the task pane; related, not the same ask): https://techcommunity.microsoft.com/idea/microsoft365developerplatform/outlook-itemsend-event-as-a-standard-office-eventtype-usable-in-taskpane-code/3260807

 

(This post was drafted with the help of an AI assistant and checked against the linked documentation.)

No CommentsBe the first to comment