Merge MHT

How to merge MHT files in C#

GroupDocs.Merger allows developers to merge MHT files when it’s needed to organize multiple MHT files into single document or send fewer attachments etc. And you can do this without¬†any third-party software or manual work involved. With GroupDocs.Merger it is possible to combine MHT documents of any size and structure - all text, images, tables, graphs, forms and other content will be preserved.

The following example demonstrates how to merge MHT files with several lines of C# code:

  • Create an instance of Merger class and pass source MHT file path as a constructor parameter. You may specify absolute or relative file path as per your requirements.
  • Add another MHT file to merge with Join method. Repeat this step for other MHT documents you want to merge.
  • Call Merger class Save method and specify the filename for the merged MHT file as parameter.
// Load the source MHT file
using (Merger merger = new Merger(@"c:\sample1.mht"))
{
    // Add another MHT file to merge
    merger.Join(@"c:\sample2.mht");
    // Merge MHT files ans save result
    merger.Save(@"c:\merged.mht");
}

About MHT File Format

Files with MHT extension represent a web page archive format that can be created by a number of different applications. The format is known as archive format because it saves the web HTML code and associated resources in a single file. These resources include anything linked to the webpage such as images, applets, animations, audio files and so on.

Code Examples

Please find more use-cases and complete C# sources of our backend and frontend examples and try them for free!

Merge MHT Live Demo

GroupDocs.Merger for .NET provides an online MHT Merger App, which allows you to try it for free and check its quality and accuracy.

“Merge MHT”