How to get right MIME type for .MSG file while uploading file?

When uploading a file,  with extension ".msg" (Outlook E-mail File), the FileUpload UI Element does not show the correct MIME type. In this case, the expected MIME type is "application/", however the UI element shows the MIME type as "application/octet-stream", which is the generic file type.

The function used to detect MIME type is GetFileMimeType() from MimeType module and for .msg file, it always returns MIME type as "application/octet-stream". Also configured MIME type mapping for .MSG file in IIS server.


Hi Nilam,

I did some search based on the mentioned context and found some of the pointers releated to it. 

  • The file.type attribute is returning blank in case of .msg file upload
  •  The  issue/problem that the browser doesn't return correct mime-type for outlook-msg-files. Instead of application/ the type-property of File shows an empty string

Reference links:

I could suggest you a work-around i.e. Using JavaScript, you can get the uploaded File type, referring to the file extesnion as mentioned-below.

JavaScript Snippet:

var control = document.querySelector("#" + $parameters.UploadWidgetId + " > input");

if (window.FileReader && window.Blob) {
    // All the File APIs are supported.
    control.addEventListener("change", function(event) {
    // When the control has changed, there are new files
        var files = control.files;
        var i = 0, fileType = "";
        if (files[i].name !== null && files[i].name !== undefined && files[i].name.endsWith(".msg")) {
                fileType = "application/";
         $actions.SetFileInfo(files[i].type || fileType, files[i].size);
    }, false);
} else {
    // File and Blob are not supported

See this sample screen UploadWidget_MSG Demo

Refer to the attached .oml file

Hope this helps you!

Kind regards,

Benjith Sam

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.