3

Outlook JavaScript API deprecation for AttachmentDetails.contentType property

 2 years ago
source link: https://devblogs.microsoft.com/microsoft365dev/outlook-javascript-api-deprecation-for-attachmentdetails-contenttype-property/?WT_mc_id=DOP-MVP-4025064
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Outlook JavaScript API deprecation for AttachmentDetails.contentType property 

January 26th, 2022

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! 


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK