Sharepoint – Open .eml files in Outlook

If you use email enabled document libraries or indeed any other method of storing email messages (commonly created in Exchange / Outlook) in Sharepoint document libraries then they are more than likely stored in .eml format (that first appeared in Outlook Express) as opposed to the more modern .msg format. .eml is a nice format, which was defined in MIME RFC 822 but because it’s so heavily ingrained in to a Windows environment there can be a less than desirable experience when operating with it in a Sharepoint context.

One of two things is likely to happen when you try and open an .eml file from Sharepoint:

  1. It will open directly in the browser
  2. It will prompt you to Save the file to your computer, from there you can open it in e.g, Outlook

Whilst this is likely to be OK in the majority of cases, there are some drawbacks:

  1. If files open in the browser, then they will likely render OK – but you won’t see any of the extended properties, have any email functionality and you won’t see any attachments on the email
  2. Having to save a file, open the folder, find the item, click to open, and then finally view it is a bit convoluted for the end user

Wouldn’t it be nice if we could just open an .eml file in a Sharepoint library and it open automatically in Outlook? Yep, it would, but it’s not entirely straight-forward on how to do it because there are various factors at play:

  1. How Sharepoint handles the .eml file type
  2. How IIS handles the .eml file type
  3. Which browser you’re using and how it handles the .eml file type
  4. Which OS you’re using and how it handles the .eml file type

Fun huh?

There are a lot of people out there talking about solutions some of which include reference to:

  1. Change the web application file handling permission from Strict to Permissive – this is a setting that determines whether Sharepoint appends special headers to files when they’re downloaded – the advice is generally that it needs to be set to Permissive – but doesn’t look at the consequences of doing this (which I’m not going to either, other than to say strict is best practice and if you are set to strict then it’s likely for a reason – you can really break other things if you flip this flag – e.g., such as how Sharepoint works with Excel files.)
  2. Update IIS handling of mime types
  3. The Site Collection feature “Open files in client application”
  4. Some posts even suggest / recommend – modifiying the registry! – this makes me weep. This would never be acceptable in a business scenario.

After a fair bit of experimenting, IIS resetting and swearing (naturally) this is what worked for me and seems to be the minimum amount of changes required. Your mileage may vary based on your environment.

The environment is:

  • Sharepoint 2010 SP2, with two SP servers in the farm
  • Windows Server 2008 R2 with IIS7
  • .eml files in Document Sets in Document Libraries (duh)
  • Client application is 64 bit Windows 10 with Internet Explorer 11.2670.14393 and Chrome 71.0.3578
  • Outlook 2016

I found that:

  1. You don’t need to change web application browser file handling (i.e., it can be strict)
  2. You don’t need to modify the registry (thank f*ck)
  3. You don’t need the site collection features
  4. You do need to tweak IIS
  5. You do need server access to tweak the web application

Step 1: Check .eml is configured for use with Outlook

Will start with the most basic things, and that’s to check that Outlook is properly configured on the client machine to open .eml files by default.

This is likely to be true already – if you download an .eml file to the machine and then the icon changes to the Outlook icon, then that means it is.

But verify anyway by checking in Control Panel > Default programs that .eml is configured for Outlook. You can do this a different way via Internet Explorer > Internet Options > Programs. It all resolves to the same place though.

Step 2: Check your library(ies)

This is also a fairly basic check but worth it for belt and braces. The site collection has an ‘Open files in client application’ feature… which you can enable, but you don’t need to.

The libraries themselves also have handling properties which are worth checking. You can do this via the Document Library settings > Advanced Settings or by Powershell.

We’re checking two things – browser file handling attribute (will likely match the web application) and also the default item open mode.

$web = Get-SPWeb http://yourweb
$list = $web.Lists["Your List"]
$list.BrowserFileHandling # will be Permissive or Strict (and should match web app.) In my testing it could be either but if you do need Permissive then you're <em>probably</em> better setting it here rather than the web application.
$list.DefaultItemOpen # should be PreferClient (or $null if the server default is PreferClient)
$list.DefaultItemOpen = "PreferClient"
$list.Update()

Obviously if you have lots of libraries you’ll probably want to put that in a function and looping and so forth.

Step 3: Update SP Web application to use this new mime type

I can’t find a way to do this through Central Admin UI, so Powershell it is. Pick a Sharepoint server and open up Powershell as Administrator etc… and

$webApp = Get-SPWebApplication http://yourwebapp
$webApp.AllowedInlineDownloadedMimeTypes.Add("application/octet-stream")
$webApp.Update()

Step 4: Update IIS handling of .eml mime type

On each Sharepoint server, open up IIS Manager and then in the left click at the server level (as opposed to the web application level) and open up MIME Types from the main panel on the right.

Scroll through this list to find .eml and it is most likely configured to be message/rfc822. Edit the value and change it to be application/octet-stream. Save out and iisreset on all Sharepoint servers.

Note: The reason I’ve highlighted “at the server level” is because I previously tried this at the web application level only (thinking this would be enough) and it did not work. There could be numerous reasons why not – it might be that the browser file handling is gathered actually from Central so it might be that change it for the content web application and the Central Admin web application is enough but I didn’t try this…

Now that should be all you need and clicking an .eml file now should yield an ‘Open’ button.

Magic.

Be the first to comment

Leave a Reply

Your email address will not be published.


*