Sunday, April 20, 2014 
   home about us faq contact us
PRODUCT
  What is it?
  Features
  FAQ
  Licensing
   
EVALUATION
  On-Line Demo
  Download
   
PURCHASE
  Buy Now!
   
SUPPORT
  Class Reference
  Mailing List
  Examples
  Support Forums
   
Other Email Products
  aspNetEmail
  aspNetMime
  aspNetMX
  aspNetPOP3
  ListNanny
   
Networking Products
  aspNetDNS
  aspNetPing
  aspNetTraceRoute
  aspNetWhois
   

Examples and Documentation

Documentation
Online Help
Downloadable .chm Help File

Support
    Email Support
    Telephone Support

Online Forums
    Advanced Intellect's Online Forums
    Yahoo "Anything .NET and Email" Peer Support Group

Examples

  • Converting a Url to a MHT Document
  • Logging with aspNetMHT
  • Converting a HTML string to a MHT Document
  • Converting a HTML file to a MHT Document

    Converting a Url to a MHT Document
    This sample is a short and simple example demonstrating the capability of aspNetMHT to convert a URL to a MHT document.

    [ C# ]
    string url = "http://www.google.com";
    
    //create a unique filename because .mht 
    //files are cached by IE so any changes made 
    //to the same file will not be reflected 
    //unless the IE cache is cleared
    string filename 
     = "c:\\temp\\" + DateTime.Now.ToFileTime().ToString() + ".mht"; 
    
    MHT m = new MHT( url );
    
    //parse the HTML into it's MHT counterpart
    m.Parse();
    
    //save it to the filesystem
    m.SaveToFile( filename );
    
    

    [ VB.NET ]
    Dim url As String = "http://www.google.com"
    
    'create a unique filename because .mht 
    'files are cached by IE so any changes made 
    'to the same file will not be reflected 
    'unless the IE cache is cleared
    Dim filename As String 
     = "c:\temp\" + DateTime.Now.ToFileTime().ToString() + ".mht"
    
    Dim m As New MHT(url)
    
    'parse the HTML into it's MHT counterpart
    m.Parse()
    
    'save it to the filesystem
    m.SaveToFile(filename)
    
    




    Logging with aspNetMHT
    This sample is a short and simple example demonstrating the capability of aspNetMHT to convert a URL to a MHT document with the additional feature of enabling logging for any troubleshooting purposes.

    [ C# ]
    string url = "http://www.google.com";
    
    //create a unique filename because .mht 
    //files are cached by IE so any changes made 
    //to the same file will not be reflected 
    //unless the IE cache is cleared
    string filename 
     = "c:\\temp\\" + DateTime.Now.ToFileTime().ToString() + ".mht"; 
    MHT m = new MHT();
    
    //enable logging for any troubleshooting
    string logfile = "c:\\temp\\mht.log";
    m.Logger = new MHTLog( logfile );
    m.Logger.Enabled = true;
    m.Logger.Overwrite = true;
    
    //load the content from a remote url
    m.LoadUrl( url );
    
    //parse the HTML into it's MHT counterpart
    m.Parse();
    
    //save it to the filesystem
    m.SaveToFile( filename );
    
    

    [ VB.NET ]
    Dim url As String = "http://www.google.com"
    
    'create a unique filename because .mht 
    'files are cached by IE so any changes made 
    'to the same file will not be reflected 
    'unless the IE cache is cleared
    Dim filename As String 
     = "c:\temp\" + DateTime.Now.ToFileTime().ToString() + ".mht"
    Dim m As New MHT()
    
    'enable logging for any troubleshooting
    Dim logfile As String = "c:\temp\mht.log"
    m.Logger = New MHTLog(logfile)
    m.Logger.Enabled = True
    m.Logger.Overwrite = True
    
    'load the content from a remote url
    m.LoadUrl(url)
    
    'parse the HTML into it's MHT counterpart
    m.Parse()
    
    'save it to the filesystem
    m.SaveToFile(filename)
    
    


    Converting a HTML string to a MHT Document
    This sample builds a MHT document from a HTML formatted string.

    [ C# ]
    //create a unique filename because .mht files are cached by IE
    
    //create a unique filename because .mht 
    //files are cached by IE so any changes made 
    //to the same file will not be reflected 
    //unless the IE cache is cleared
    string filename 
     = "c:\\temp\\" + DateTime.Now.ToFileTime().ToString() + ".mht"; 
    MHT m = new MHT();
    
    //enable logging for any troubleshooting
    string logfile = "c:\\temp\\mht.log";
    m.Logger = new MHTLog( logfile );
    m.Logger.Enabled = true;
    m.Logger.Overwrite = true;
    
    //load the content from a remote url
    string html = "<html><body>Here is a picture of the company 
     logo <img src='http://www.mycompany.com/logo.gif'></body></html>";
    m.LoadString( html );
    
    //parse the HTML into it's MHT counterpart
    m.Parse();
    
    //save it to the filesystem
    m.SaveToFile( filename );
    
    

    [ VB.NET ]
    'create a unique filename because .mht files are cached by IE
    'create a unique filename because .mht 
    'files are cached by IE so any changes made 
    'to the same file will not be reflected 
    'unless the IE cache is cleared
    Dim filename As String 
     = "c:\temp\" + DateTime.Now.ToFileTime().ToString() + ".mht"
    Dim m As New MHT()
    
    'enable logging for any troubleshooting
    Dim logfile As String = "c:\temp\mht.log"
    m.Logger = New MHTLog(logfile)
    m.Logger.Enabled = True
    m.Logger.Overwrite = True
    
    'load the content from a remote url
    Dim html As String 
     = "<html><body>Here is a picture of the company 
     logo <img src='http://www.mycompany.com/logo.gif'></body></html>"
    m.LoadString(html)
    
    'parse the HTML into it's MHT counterpart
    m.Parse()
    
    'save it to the filesystem
    m.SaveToFile(filename)
    
    


    Converting a HTML file to a MHT Document
    This sample builds a MHT document from a local HTML file.

    [ C# ]
    //create a unique filename because .mht files are cached by IE
    //create a unique filename because .mht 
    //files are cached by IE so any changes made 
    //to the same file will not be reflected 
    //unless the IE cache is cleared
    string filename 
     = "c:\\temp\\" + DateTime.Now.ToFileTime().ToString() + ".mht"; 
    MHT m = new MHT();
    
    //enable logging for any troubleshooting
    string logfile = "c:\\temp\\mht.log";
    m.Logger = new MHTLog( logfile );
    m.Logger.Enabled = true;
    m.Logger.Overwrite = true;
    
    //explicitly allow aspNetMHT to read from the filesystem
    m.AllowFileScheme = true; 
    
    //load the content from a local file
    m.LoadFile( "c:\\temp\\sample.htm");
    
    //parse the HTML into it's MHT counterpart
    m.Parse();
    
    //save it to the filesystem
    m.SaveToFile( filename );
    
    



    [ VB.NET ]
     'create a unique filename because .mht files are cached by IE
    'create a unique filename because .mht 
    'files are cached by IE so any changes made 
    'to the same file will not be reflected 
    'unless the IE cache is cleared
    Dim filename As String 
     = "c:\temp\" + DateTime.Now.ToFileTime().ToString() + ".mht"
    Dim m As New MHT()
    
    'enable logging for any troubleshooting
    Dim logfile As String = "c:\temp\mht.log"
    m.Logger = New MHTLog(logfile)
    m.Logger.Enabled = True
    m.Logger.Overwrite = True
    
    'explicitly allow aspNetMHT to read from the filesystem
    m.AllowFileScheme = True
    
    'load the content from a local file
    m.LoadFile("c:\temp\sample.htm")
    
    'parse the HTML into it's MHT counterpart
    m.Parse()
    
    'save it to the filesystem
    m.SaveToFile(filename)
    
    







  "Tried the fix you directed me to on the FAQ/KB page. It worked fine. Thanks for your prompt assistance. I have no doubt that we will be evaluating, and likely purchasing, your POP3 product next."
B.A. Lewis
U.S. Army
 
More Testimonials

 
OTHER PRODUCTS
Click here to learn more +  
 This site's email addresses are protected by EmailSpoofer.NET.   2014 © AdvancedIntellect
All rights reserved