none
Change registry settings to open eml file from web pages in outlook express

    Question

  • I couldn't find an appropriate forum which would suit the type of problem I am facing so I am putting it here.

    I needed to create an intranet web application that has pages with hyperlinks to eml files. The eml files as is known are email files in MIME format which outlook express can open.

    However what I found was if eml files are on your machine, it opens in outlook express but when opened as an hyperlink, it opens in Internet Explorer (IE) as an mhtml file.  And any attachments that may be in the eml file are not displayed at all!

    I didn't understand why IE has to poke inbetween. After searching the net, I came across a solution that required changes in the Registry of the client machine.

    The change is to be made to the node HKEY_CLASSES_ROOT\MIME\Database\Content Type\message/rfc822.

    The following is a REG file that can be imported for this change.

    [HKEY_CLASSES_ROOT\MIME\Database\Content Type\message/rfc822]
    "extension"=".eml"
    "CLSID"=""

    However after this change, though eml files opened in Outlook express, MHT files stopped opening in IE.

    Then I simply deleted the rfc822 node and to my surprise, MHT files opened in IE and eml files opened in outlook express and everything was fine!!

    But I don't want to use this sledge hammer solution.  I want to know what this registry key is for and how can I set it to achieve what I want . i.e. open  eml files from web pages in outlook express without affecting other file types

    &=1
    • Edited by devanalyst Thursday, July 10, 2008 8:38 AM correction
    Thursday, July 10, 2008 8:36 AM

Answers

  • Delving into this further, I came to know why deleting the rfc822 key solves the problem.
     In the HKEY_CLASSES_ROOT registry hive, there are registry keys for .eml, .mht, .mhtml extensions that have a key 'ContentType' with value 'message/rfc822'.
    Thus for any file from the internet with any of the above extensions, this is the content type associated.

    And in the HKEY_CLASSES_ROOT\MIME\Database\Content Type\message/rfc822, there is a key CLSID. The value of the CLSID is the class id of the software that will be used to open such files from the internet. By default it is CLSID of mhtml.

    So deleting this key led the OS to look for other options to open files with .eml extension which was Outlook Express.

    One option to solve my problem was to change this CLSID to that of Outlook Express but .mht and .mhtlml files cannot be read by Outlook Express so this solution is not acceptable.

    A more better solution would be to 'tell' the registry that if content type is message/rfc822 and file extension is .eml then open it in outlook express else use Internet Explorer.

    The question is how to do this. Can the Registry gurus out there help me on this?





    &=1
    • Edited by devanalyst Friday, July 11, 2008 6:35 AM Correction
    • Marked as answer by Martin Xie - MSFT Wednesday, July 16, 2008 12:48 PM
    Friday, July 11, 2008 5:23 AM
  • Here is the solution. As mentioned by maxwe789, it requires creation of an download page that streams the eml file as an application/octet stream. However, this code can be used for any file type

     

    Dim FileName As String = "StreamFile.eml" 
    Dim FullFileName As String = Server.MapPath("/DownloadDir/")  & "\" & FileName 
    Response.Clear()  
    Response.ClearContent()  
    Response.ClearHeaders()  
    Response.ContentType = "application/octet-stream; name=" & FileName  
    Response.AddHeader("content-transfer-encoding", "binary")  
    Response.AppendHeader("Content-Disposition", "attachment;filename=" & FileName)  
    Response.ContentEncoding = System.Text.Encoding.GetEncoding(1251)  
    Response.WriteFile(FullFileName)  
    Response.End() 

    maxwe789 has mentioned another solution in a post here that requires changes to IIS Server settings and does not require a download page. However that solution did not work for me.

    &=1
    • Marked as answer by devanalyst Wednesday, February 04, 2009 6:54 AM
    Wednesday, February 04, 2009 6:27 AM

All replies

  • Delving into this further, I came to know why deleting the rfc822 key solves the problem.
     In the HKEY_CLASSES_ROOT registry hive, there are registry keys for .eml, .mht, .mhtml extensions that have a key 'ContentType' with value 'message/rfc822'.
    Thus for any file from the internet with any of the above extensions, this is the content type associated.

    And in the HKEY_CLASSES_ROOT\MIME\Database\Content Type\message/rfc822, there is a key CLSID. The value of the CLSID is the class id of the software that will be used to open such files from the internet. By default it is CLSID of mhtml.

    So deleting this key led the OS to look for other options to open files with .eml extension which was Outlook Express.

    One option to solve my problem was to change this CLSID to that of Outlook Express but .mht and .mhtlml files cannot be read by Outlook Express so this solution is not acceptable.

    A more better solution would be to 'tell' the registry that if content type is message/rfc822 and file extension is .eml then open it in outlook express else use Internet Explorer.

    The question is how to do this. Can the Registry gurus out there help me on this?





    &=1
    • Edited by devanalyst Friday, July 11, 2008 6:35 AM Correction
    • Marked as answer by Martin Xie - MSFT Wednesday, July 16, 2008 12:48 PM
    Friday, July 11, 2008 5:23 AM
  • Did you ever find an answer to this, i made the change as you showed and that helped, but would be greatful for any assistance as a long term fix.
    Sunday, October 26, 2008 11:03 PM
  •  Unfortunately I couldn't find any other solution other than deleting the registry key. Since windows treats both MHT file and EML file content from web pages as MIME (rfc822), both are associated with a common registry key. 
    &=1
    Monday, October 27, 2008 7:50 AM
  • using your web application couldn't you stream the eml from the webserver setting the content type manually to "application/octet-stream". Web application change and doesn't require all of your client machines to have the registry changed.

    You would have to write a download page and link to it rather than link directly to the file.
    Wednesday, October 29, 2008 4:27 PM
  • Right, got the best solution (server side), I didn't realise how easy it is to change the default MIME type for eml in IIS. You must go to the top level "My Computer" icon in IIS 6 manager (I don't know where it is in IIS7 but I'm sure it is somewhere in there). Don't go to the Web site section as that will only let you add more MIME types not edit existing ones. Right click the icon and click properties then click MIME types. In there you will see eml is listed as message/rfc822. Change that to be application/octet-stream and job done.
    • Proposed as answer by maxwe789 Thursday, October 30, 2008 9:43 AM
    Thursday, October 30, 2008 9:41 AM

  • maxwe789 said:

    Right, got the best solution (server side), I didn't realise how easy it is to change the default MIME type for eml in IIS. You must go to the top level "My Computer" icon in IIS 6 manager (I don't know where it is in IIS7 but I'm sure it is somewhere in there). Don't go to the Web site section as that will only let you add more MIME types not edit existing ones. Right click the icon and click properties then click MIME types. In there you will see eml is listed as message/rfc822. Change that to be application/octet-stream and job done.


    I did the setting you mentioned on the IIS 6 server but it did not have any effect on the client side. The client side browser still opens the eml files in Internet Explorer.  I then added the eml MIME type directly to the site with application/octet-stream as the content type but still it did not work. Did u test the solution at your end ?


    &=1
    Monday, February 02, 2009 7:13 AM
  • Here is the solution. As mentioned by maxwe789, it requires creation of an download page that streams the eml file as an application/octet stream. However, this code can be used for any file type

     

    Dim FileName As String = "StreamFile.eml" 
    Dim FullFileName As String = Server.MapPath("/DownloadDir/")  & "\" & FileName 
    Response.Clear()  
    Response.ClearContent()  
    Response.ClearHeaders()  
    Response.ContentType = "application/octet-stream; name=" & FileName  
    Response.AddHeader("content-transfer-encoding", "binary")  
    Response.AppendHeader("Content-Disposition", "attachment;filename=" & FileName)  
    Response.ContentEncoding = System.Text.Encoding.GetEncoding(1251)  
    Response.WriteFile(FullFileName)  
    Response.End() 

    maxwe789 has mentioned another solution in a post here that requires changes to IIS Server settings and does not require a download page. However that solution did not work for me.

    &=1
    • Marked as answer by devanalyst Wednesday, February 04, 2009 6:54 AM
    Wednesday, February 04, 2009 6:27 AM
  • you probably are talking about eml files in SharePoint document library. I have the exactly same issue. The client side solution helped me - change the file assoication in registry as you recommended.
    Wednesday, April 13, 2011 3:26 PM