MakeArchiveStream Method


Builds MHT web archives and writes the MHT into the specified output stream. The method is especially useful if you need to send MHT file as as response to client from a server ASP script.

IMPORTANT 1: If you use this method in ASP, you will need to add "x=.mht" as a last query parameter to this page (you may replace 'x' with any string). For example: http://server_name/getarchive.asp?a=b&x=.mht. This trick is designed to avoid security restrictions implemented in Internet Explorer 6.0 build 2800 and later.

IMPORTANT 2:  It is not recommended to call this method with input URLs, but if it's absolutely necessary, please make sure that SpiderLevel property is set according to your needs.   

ActiveX Script Syntax

Show Syntax

ActiveX C++ Syntax

Show Syntax

Library C++ Syntax

Show Syntax

ASP Sample: VB Script (without error handling)


<%@ Language=VBScript%>

' Create web archive object
Set oWebArchive = Server.CreateObject("WebArchiveX.Builder")

' Set correct content type for the web archive
Response.ContentType = "message/rfc822"

' Make archive and write the MHT directly into Response
oWebArchive.MakeArchiveStream "C:\inetpub\wwwroot\test\test.html",
        Request.ServerVariables("HTTP_USER_AGENT"),
        Response


ASP Sample: JavaScript (with error handling)


<%@ Language=JavaScript%>

try
{
    // Create web archive object
    var webArchive = new ActiveXObject("WebArchiveX.Builder");

    // Set correct content type for the web archive
    Response.ContentType = "message/rfc822";

    // Make archive and write the MHT directly into Response
    webArchive.MakeArchiveStream("c:\\inetput\\wwwroot\\sample.htm",
        Request.ServerVariables("HTTP_USER_AGENT"),
        Response);
}
catch(e)
{
    Response.ContentType = "text/html";
    Response.Write("ERROR: " + e.description);
}

 

- WebArchiveX API - WebArchiveX Website - C Systems Website


C Systems - Creative software solutions since 1996. All rights reserved. Terms of use.