Issue with getAttachmentContentAsync when trying to fetch inline image attachment content

Marjolein Bente 0 Reputation points
2025-10-03T13:40:54.63+00:00

I am working on an outlook web add-in and encountered an issue with getAttachmentContentAsync. My goal is to retrieve all mail content, including inline attachments, when a mail is sent. Retrieving inline images upon sending the mail is the issue I am experiencing here.

In a specific set of circumstances getAttachmentContentAsync does not return any content and the associated GetFileAttachment request returns a 404 error. The getAttachmentsAsync method does work in these circumstances; I can retrieve details like attachment name, ID, and size.

The circumstances in which the issue occurs are when a user has pasted an inline image before selecting a specific panel in our add-in in the taskpane. When in this specific panel a specific setting is set to default, it makes an api call to our server during the mounting of a (Vue) sub component in this panel. Delaying this api call to our server with a timeout “solved” the issue. If the api call takes place after mounting, it doesn’t cause any issues and content is retrieved. If the relevant setting is not on default and therefore not causing an api call during mounting, content is also successfully retrieved. Using await Office.onReady() during the mounting of the Vue sub component very intermittently resulted in success, but overall did not resolve the issue. We already perform an Office.initialize() when creating the app in the main.js.

Steps to reproduce:

(In our database a specific setting must be set to true so the api call to our server is made during the mounting of the subcomponent)

  1. Compose a new email
  2. Add recipients, subject and body which includes an inline image.
  3. Open our add-in (this can also be step 1, makes no difference)
  4. Select the panel that lets the issue occur
  5. Click on the send button

I have more documentation on which set of steps exactly will cause failures or successes.

Expected behavior:

I am able to fetch the attachment content in base64 format.

Current behavior:

The GetFileAttachmentId request returns a 404 when trying to fetch inline attachment content using Office.context.mailbox.item.getAttachmentContentAsync; the content is not retrieved.

Setups:

  • Outlook web on Firefox on MacOS
  • New Outlook on Windows 11 via Parallels on MacOS

I’m not sure what is causing this; are there known limitations or issues with getAttachmentContentAsync? Any suggestions or insight anyone could offer would be greatly appreciated!

If you need any more information, please let me know.

Microsoft 365 and Office | Development | Office JavaScript API
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jack-Bu 4,590 Reputation points Microsoft External Staff Moderator
    2025-10-03T14:11:17.51+00:00

    Hello Marjolein Bente,

    Thank you for reaching out to Microsoft Q&A forum about the issue with your Outlook web add-in.

    Regarding the situation, when the getAttachmentContentAsync API fails with an underlying 404 error on the GetFileAttachment request, while getAttachmentsAsync works correctly. This could happen in specific scenarios: when an inline image is added before selecting a particular panel in your add-in, and when a default setting triggers a server API call during the mounting of a Vue subcomponent in that panel. Delaying or avoiding that API call during mount seems to prevent the issue. You've tested this on Outlook web (Firefox on macOS) and New Outlook (Windows 11 via Parallels on macOS) and using Office.onReady() helps sporadically but not consistently.

    This appears to be related to timing or race conditions in the Office.js API during the ItemSend event, possibly interacting with your add-in's lifecycle and network calls. It's consistent with some reported behaviors in compose/send scenarios, but to pinpoint the exact cause and provide targeted guidance, I need more details from your implementation.

    Could you please share the following code snippets (please, remember to redact any sensitive info)?

    • The handler for the ItemSend or OnMessageSend event where you're calling getAttachmentContentAsync.
    • The Vue subcomponent's mount logic (e.g., the mounted() hook) that triggers the server API call.
    • Any relevant parts of your main.js where Office.initialize() is set up.

    Once I have these, I can analyze them further. Let me know if you have any questions in the meantime.I am looking forward to your reply.


    Please understand that our initial response may not always resolve the issue immediately. However, with your further updates and more detailed information, we can work together to find a resolution. 

    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.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.