An Office service that supports add-ins to interact with objects in Office client applications.
Based on my review of the available documentation and behavior described, I am happy to share the insights I have gathered so far regarding your questions.
Before continuing, I would like to clarify that Microsoft Q&A is a user-to-user support forum. Moderators and contributors, including Microsoft employees participating externally, are not able to intervene in product behavior or access internal systems. Our role is limited to sharing documented behavior, supported guidance, and practical insights based on experience.
1/ Does Office.js return a fallback empty object when translateExchangeIds fails internally?
Microsoft’s documentation does not describe any intentional fallback or placeholder object for this scenario. Typically, API failures are reported through errors in asynchronous callbacks.
However, the presence of a truthy but empty object, together with a 403 Forbidden error from the translateExchangeIds call in the console, indicates that the add‑in did not receive the expected data from the server. In compose mode, Office.context.mailbox.item acts mainly as a reference handle. If the background process that populates this handle does not complete successfully, the object may still exist but contain no usable properties.
2/ Will re-reading Office.context.mailbox.item after a delay return a hydrated item, or is the failed state cached until the next ItemChanged event?
Accessing Office.context.mailbox.item gives you a reference to the current message, but in compose mode most of its data is not available directly. Instead, properties such as the item ID or subject must be retrieved using asynchronous APIs like getItemIdAsync or subject.getAsync.
According to Microsoft documentation, whether these calls succeed can depend on the item’s current state and its synchronization progress. Each asynchronous call is a separate request to the Outlook system, so calling the same API again after a short delay is the supported way to check whether the item has become available or whether a temporary sync delay has cleared.
Reference: Office.MessageCompose interface - Office Add-ins | Microsoft Learn
There is no documentation stating that a failed retrieval is permanently stored until the next ItemChanged event. For this reason, retrying asynchronous retrieval remains the recommended and supported approach when the initial call does not return the expected data.
3/ What's the recommended way to detect this degenerate state, given the object is truthy and itemId being undefined is valid in compose mode?
A robust approach is to use the asynchronous APIs and inspect their results as part of your item validation flow:
- Use getItemIdAsync: In compose mode, call
Office.context.mailbox.item.getItemIdAsync() - Examine the Status: Check if
asyncResult.status === Office.AsyncResultStatus.Failedand examineasyncResult.error.code. you should look for codes like ItemNotSaved to identify why the request did not succeed. - Validate Before Proceeding: Only after successfully retrieving a valid ID should you proceed to
convertToRestId
Reference:
- Office.MessageCompose interface - Office Add-ins | Microsoft Learn
- Office.AsyncResult interface - Office Add-ins | Microsoft Learn
*Regarding your retry proposal:
Yes. As mentioned earlier, the item may require time to synchronize. Retrying the item retrieval up to three times, with approximately a 1.5 second delay between attempts, is a reasonable and supported approach. This aligns with Microsoft guidance on handling synchronization timing in cached scenarios and ItemNotSaved responses when calling getItemIdAsync.
I hope the information above provides some additional insight. If you have any updates or have further details to share, please feel free to let me know.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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