{"id":9373,"date":"2022-01-26T07:20:34","date_gmt":"2022-01-26T15:20:34","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/?p=9373"},"modified":"2022-05-25T17:06:05","modified_gmt":"2022-05-26T00:06:05","slug":"outlook-javascript-api-deprecation-for-attachmentdetails-contenttype-property","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/outlook-javascript-api-deprecation-for-attachmentdetails-contenttype-property\/","title":{"rendered":"Outlook JavaScript API deprecation for contentType property"},"content":{"rendered":"<p><span data-contrast=\"auto\">The <\/span><span data-contrast=\"none\">AttachmentDetails.contentType property<\/span><span data-contrast=\"auto\"> in the Outlook JavaScript Mailbox 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 <\/span><span data-contrast=\"auto\">contentType<\/span><span data-contrast=\"auto\"> property is a direct lookup of the attachment\u2019s extension, the internal mapping isn\u2019t actively maintained or standardized. As such, we\u2019ve deprecated this property and recommend you grab the attachment\u2019s extension and process accordingly.<\/span><span data-ccp-props=\"{&quot;134233279&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\"> For example, read the <a href=\"https:\/\/github.com\/OfficeDev\/office-js\/issues\/1763\">ContentType returns unexpected values<\/a> issue in the GitHub office-js repo.<\/span><\/p>\n<h2>Code sample: contentType property deprecation<\/h2>\n<p><span data-contrast=\"auto\">The following sample code gets the attachment\u2019s file extension then handles if it\u2019s an mp4 video file.<\/span><span data-ccp-props=\"{&quot;134233279&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<pre class=\"prettyprint\">var fileExtension = Office.context.mailbox.item.attachments[0].name.split(\".\").pop().toLowerCase(); \r\n\r\nif (fileExtension == \"mp4\") { \r\n  console.log(\"This is a video file\"); \r\n}<\/pre>\n<p><span data-contrast=\"auto\">The <\/span><span data-contrast=\"auto\">contentType<\/span><span data-contrast=\"auto\"> property is still available to add-ins that currently use it. However, we advise you to replace the reference as soon as possible.<\/span><span data-ccp-props=\"{&quot;134233279&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">New add-ins should avoid using this property at all.<\/span><span data-ccp-props=\"{&quot;134233279&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n<h3>More resources<\/h3>\n<ul>\n<li><a href=\"https:\/\/developer.microsoft.com\/outlook\">Outlook Developer Center<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/javascript\/api\/overview?view=outlook-js-preview\">Outlook JavaScript API reference<\/a><\/li>\n<li><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/category\/office-add-ins\/\">Office Add-ins blogs<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/javascript\/api\/outlook\/office.attachmentdetails?view=outlook-js-preview\">Office.AttachmentDetails interface<\/a><\/li>\n<\/ul>\n<p><span data-contrast=\"auto\">Happy coding!<\/span><span data-ccp-props=\"{&quot;134233279&quot;:true,&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:240}\">\u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to manage your add-in with the deprecation of the AttachmentDetails.contentType property\u00a0for the Outlook JavaScript API.<\/p>\n","protected":false},"author":69076,"featured_media":9382,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[11],"tags":[12],"class_list":["post-9373","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-office-add-ins","tag-outlook"],"acf":[],"blog_post_summary":"<p>Learn how to manage your add-in with the deprecation of the AttachmentDetails.contentType property\u00a0for the Outlook JavaScript API.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/9373","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/users\/69076"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/comments?post=9373"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/9373\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media\/9382"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media?parent=9373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/categories?post=9373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/tags?post=9373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}