Skip to content
Advertisement

How is Outlook Online downloading attachments?

I’m trying to understand how the “Download All” button works in Office365 Outlook Online when downloading multiple attachments from an email.

Download All button

The button is a “button” type. It does not appear to be part of a form. It has some “click” event listeners (apparently using React), but I’m not able to understand if those are somehow resulting in the download firing.

JavaScript

When I click it, Chrome doesn’t show a network event at all in the Network tab. Firefox shows it as a GET request, and it doesn’t look like XmlHttpRequest (no Origin header etc):

Request:

JavaScript

Response:

JavaScript

I’m unable to tell what mechanism is used to fire this request: page navigation, XmlHttpRequest, Fetch?.. What makes the browser treat it as an attachment? I tried to intercept this response in Fiddler and change the response headers to

JavaScript

But the browser still downloads the response as a file, rather than rendering it inline. Why is that?

Advertisement

Answer

This is caused by a dynamically added anchor tag with a download attribute:

JavaScript

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#download

If Content-Disposition has a different filename than download, the header takes priority. (If Content-Disposition: inline, Firefox prefers the header while Chrome prefers download.)

Advertisement