Wednesday, March 30, 2005

Convert any URL to a MHTML archive using native .NET code

The Code Project - Convert any URL to a MHTML archive using native .NET code - VB.NET

".. If you've ever used the File | Save As... menu in Internet Explorer, you might have noticed a few interesting options IE provides under the Save As Type drop-down box.

The options provided are:

Web Page, complete
Web Archive, single file
Web Page, HTML only
Text File

Most of these are self-explanatory, with the exception of the Web Archive (MHTML) format. What's neat about this format is that it bundles the web page, and all of its references, into a single compact .MHT file. It's a lot easier to distribute a single self-contained file than it is to distribute a HTML file with a subfolder full of image/CSS/Flash/XML files referenced by that HTML file. In our case, we were generating HTML reports and we needed to check these reports into a document management system which expects a single file. The MHTML (*.mht) format solves this problem beautifully!

This project contains the MhtBuilder class, a 100% .NET managed code solution which can auto-generate a MHT file from a target URL, in one line of code. As a bonus, it will also generate all the other formats listed above, too. And it's completely free, unlike some commercial solutions you might find out there.

..."


Building Mht Files from URLs revisited

"... finally finished updating my Convert any URL to a MHTML archive using native .NET code CodeProject article. It's based on RFC standard 2557, aka Multipart MIME Message (MHTML web archive). You may also know it as that crazy File, Save As, "Web Archive, Single File" menu option in Internet Explorer. It's basically a way to package an entire web page as a (mostly) functional single file that can be emailed, stored in a database, or what have you. Lots of interesting possibilities, including quick and dirty offline functionality for ASP.NET websites using loopback HTTP requests.
..."


Very cool.

I wonder if I can use this class to create a quick and dirty Blogspot backup utility...

I'm currently using HTTrack to "back up" my blog, which works great, but it does create a lot of files (exactly as it is supposed to...). Having each of my blog posts as a single page/MHT would be pretty cool and much easier to email/store.

[Gear grinding noises can be heard coming from Greg's head...]

No comments: