Outlook JavaScript API deprecation for AttachmentDetails.contentType property 

Microsoft Office team

The AttachmentDetails.contentType property in the Outlook JavaScript API gives an add-in developer the ability to get the MIME content type of an Outlook item attachment. However, while the value returned by the contentType property is a direct lookup of the attachment’s extension, the internal mapping isn’t actively maintained. As such, we’ve deprecated this property and recommend you grab the attachment’s extension and process accordingly. 

The following sample code gets the attachment’s file extension then handles if it’s an mp4 video file. 

var fileExtension = Office.context.mailbox.item.attachments[0].name.split(".").pop().toLowerCase(); 

if (fileExtension == "mp4") { 
  console.log("This is a video file"); 
}

The contentType property is still available to add-ins that currently use it. However, we advise you to replace the reference as soon as possible. 

New add-ins should avoid using this property at all. 

Happy coding! 

0 comments

Comments are closed. Login to edit/delete your existing comments