How to add an attachment to a mail via an OWA App

September 01, 2014

For one of our company events later this month, I developed a demo OWA app which could add attachments to a mail. I used the following MSDN article to achieve this: Add and remove attachments to an item in a compose form in Outlook. In the article they give a good overview, but there is one little problem with the example code. This code does not include the file extension, so you end up with unrecognised files in OWA.

Files without extensions

Files without extensions

The first one is a JPG file, the second one a Word document. Because the file extensions are not included, the files cannot be opened in Office Web Apps.

If you would manually upload the files, you get this:

Files with extensions

Files with extensions

I contacted Microsoft, and Adam Sheldon pointed me in the right direction. He told me to check if the file extension was added in the AttachmentName property.

I quickly tested this and you do indeed need to include the file extension to the AttachmentName property.

So the example code requires an updated:

Note: only line 19 has been modified.

Note 2: this is written for the JavaScript API for Office 1.1

Comments