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
MakeArchiveStream(
String htmlFilePath,
String userAgent,
Stream oStream
);
Parameters
- htmlFilePath
- [in] String - path to the input HTML file
-
- userAgent
- [in] String - user agent string
-
- oStream
- [in] Object - output stream object
ActiveX C++ Syntax
Show Syntax
HRESULT MakeArchiveStream(
BSTR bstrHtmlFile,
BSTR userAgent,
VARIANT varStream
);
Parameters
- bstrHtmlFilePath
- [in] BSTR - path to the input HTML file
-
- userAgent
- [in] BSTR - user agent string
-
- varStream
- [in] VARIANT - output stream
Return value
Returns S_OK if successful, or an error value otherwise.
Library C++ Syntax
Show Syntax
long MakeArchive(
const std::string& htmlFile,
const std::string& userAgent,
VARIANT varStream
);
Parameters
- htmlFile
- const std::string& - path to the input HTML file
-
- userAgent
- const std::string& - user agent string
-
- varStream
- VARIANT - output stream
-
Return value
Returns 0 if successful, or an error code otherwise.
ASP Sample: VB Script (without error handling)
<%@ Language=VBScript%>
Set oWebArchive = Server.CreateObject("WebArchiveX.Builder")
Response.ContentType = "message/rfc822"
oWebArchive.MakeArchiveStream "C:\inetpub\wwwroot\test\test.html",
Request.ServerVariables("HTTP_USER_AGENT"),
Response
ASP Sample: JavaScript (with error handling)
<%@ Language=JavaScript%>
try
{
var webArchive = new ActiveXObject("WebArchiveX.Builder");
Response.ContentType = "message/rfc822";
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.