I <3 Steve McConnell*
Coding Horror
programming and human factors
by Jeff Atwood

September 13, 2004

Saving URLs to MHTML via .NET

I just posted another CodeProject article, Convert any URL to a MHTML archive using native .NET code. The title is a bit misleading; using my class, you can actually convert any URL to one of four formats in a single line of code:

  • Web Page, complete (HTML plus files in subfolder)
  • Web Archive, single file (MHTML only)
  • Web Page, HTML only (HTML only)
  • Text File (TXT only)
This mimics the File | Save As menu in Internet Explorer as closely as I could get it to. It's pretty darn close, and quite handy. We are using IE as a basic reporting engine, and it's a lot easier to email someone a report-- or store it in a document management system-- when you have a single MHTML file!

I knew IE had some crazy way of saving a complete web page as a single file, but I was as surprised as anyone else to find that IE's "Web Archive" save option is based on an actual internet standard: RFC standard 2557, compliant Multipart MIME Message (MHTML web archive). As I mentioned a few months ago, this should work in Firefox, too..

Posted by Jeff Atwood    View blog reactions

 

« Being technologically savvy isn't enough Performance Considered Harmful »

 

Comments

Firefox does NOT have MHT capability. It is planned but not yet implemented.

BTW, I posted a comment on the codeproject site
about this article. Had a chance to look at it?

Eddie Shipman on November 12, 2004 11:14 AM

Is there a way to convert bulk mht files to html?

Gina on March 1, 2006 06:48 PM

why open the mht file use your code to genereate with word 2003, it shows error, not a collect mht file, what's the problem?

michael on June 9, 2008 02:05 AM







(hear it spoken)


(no HTML)




Content (c) 2008 Jeff Atwood. Logo image used with permission of the author. (c) 1993 Steven C. McConnell. All Rights Reserved.