Mht ActiveX Reference Documentation

Mht

Current Version: 11.5.0

Chilkat.Mht

Create, save, zip, email, and unpack MHT web archives.

Chilkat.Mht creates MHT web archives and EML email messages from web pages, local HTML files, or in-memory HTML strings. It can download and embed related resources such as images, style sheets, frames, and other linked content, optionally include scripts for MHT output, use disk caching, support proxies and authentication, save or zip the generated output, and unpack existing MHT files back into HTML and supporting files.

Create MHT archives

Convert a web page, local HTML file, or HTML string into a self-contained MHT archive with related resources embedded.

Generate EML messages

Produce email-friendly MIME output from HTML content for workflows that need to send or store HTML pages as messages.

Embed page resources

Download and include images, CSS files, frames, and other supporting resources referenced by the HTML.

Network configuration

Use proxy settings, authentication, caching, and related options when fetching web pages and their dependent resources.

Save or zip output

Save generated MHT or EML content to files, return it in memory, or place the resulting output into a ZIP archive.

Unpack MHT files

Extract an existing MHT archive into an HTML file plus supporting resource files for inspection, editing, or republishing.

Common pattern: Use Mht when an application needs to capture a web page or HTML document together with its dependent resources as a single archive or email message. Provide the URL, local HTML file, or HTML string, configure any proxy, caching, authentication, or resource-handling options, then save the result as MHT, EML, memory data, or zipped output.

Object Creation

Note:
For a specific major version, use "Chilkat.Mht.<major_version>", such as "Chilkat.Mht.10" for Chilkat v10.*.*
See Chilkat ActiveX Object Creation

(ASP)
set obj = Server.CreateObject("Chilkat.Mht")

(AutoIt)
$obj = ObjCreate("Chilkat.Mht")

(Visual Basic 6.0)
Dim obj As New ChilkatMht

(VBScript)
set obj = CreateObject("Chilkat.Mht")

(VBA, such as Excel)
Dim obj As New ChilkatMht
See How to Use ActiveX in Excel

(Delphi)
obj := TChilkatMht.Create(Self);

(FoxPro)
loObject = CreateObject('Chilkat.Mht')

(PowerBuilder)
lole_object = create oleobject
li_rc = lole_object.ConnectToNewObject("Chilkat.Mht")

(SQL Server)
EXEC @hr = sp_OACreate 'Chilkat.Mht', @obj OUT

(Javascript)
var obj = new ActiveXObject("Chilkat.Mht");

Properties

AbortCurrent
AbortCurrent As Long
Introduced in version 9.5.0.58

Set to 1 to request cancellation of the operation currently running on this object. Long-running network and file operations periodically check this property; a fast operation may complete before the request is observed.

A synchronous method can be cancelled from another thread by setting this property on the same object. Chilkat resets the property to 0 after an abort is processed, and a stale request is cleared when a later method begins.

Cancellation request: Cancellation is cooperative rather than instantaneous. Always inspect the method's return value and diagnostic properties to determine the final outcome.

top
BaseUrl
BaseUrl As String

Specifies the base URL used when the source is a local HTML file or an in-memory HTML string. Relative links and resource references are resolved against this value before MHT or EML output is created.

When it is needed: A web page loaded from an HTTP or HTTPS URL already has a natural base URL. Set BaseUrl when HTML supplied from a file or string contains relative references such as images/logo.png or ../styles/site.css.

top
ConnectTimeout
ConnectTimeout As Long

Specifies the maximum number of seconds allowed for establishing a connection to an HTTP server. The default is 10 seconds.

Connection timeout only: This setting limits connection establishment; it is not a limit on the total time required to download a page. Use ReadTimeout to control inactivity while receiving data.

top
DebugHtmlAfter
DebugHtmlAfter As String

Specifies a local file path where Chilkat saves the HTML after it has been processed for MHT or EML generation. Leave the property empty to disable this diagnostic output.

Troubleshooting aid: Compare this file with DebugHtmlBefore to inspect rewritten URLs, removed scripts, and other transformations applied before the MIME document is assembled. Do not enable diagnostic output to a sensitive or publicly accessible location.

top
DebugHtmlBefore
DebugHtmlBefore As String

Specifies a local file path where Chilkat saves the source HTML before it is transformed for MHT or EML generation. Leave the property empty to disable this diagnostic output.

Troubleshooting aid: Use this together with DebugHtmlAfter to determine whether a problem originates in the input HTML or in the conversion and URL-rewriting process.

top
DebugLogFilePath
DebugLogFilePath As String

If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.

Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.

Possible causes of hangs include:

  • A timeout property set to 0, indicating an infinite timeout.
  • A hang occurring within an event callback in the application code.
  • An internal bug in the Chilkat code causing the hang.

top
EmbedImages
EmbedImages As Long

Controls whether images referenced by the HTML are downloaded or read from disk and embedded as related MIME parts. When 0, image references remain external; relative image URLs are converted to absolute URLs when sufficient base information is available.

Scope: This property controls image embedding. Other resources, such as style sheets, are handled separately by the conversion process. An MHT or EML with external image URLs is not fully self-contained and may display differently when the recipient is offline or blocks remote content.

top
EmbedLocalOnly
EmbedLocalOnly As Long

When 1, only images referenced from the local filesystem are embedded. Images referenced by HTTP or HTTPS URLs remain external. This setting is meaningful when EmbedImages is 1.

Typical use: Enable this when local application assets should be packaged but remote images should not be downloaded or included.

top
FetchFromCache
FetchFromCache As Long

When 1, Chilkat attempts to satisfy page and resource requests from the configured disk cache before downloading them. Add one or more cache directories with AddCacheRoot. The default is 0.

Related settings: UpdateCache controls whether network responses are written to the cache. IgnoreMustRevalidate and IgnoreNoCache control whether certain HTTP cache directives are honored.

top
HeartbeatMs
HeartbeatMs As Long

Specifies the interval, in milliseconds, between AbortCheck event callbacks during supported long-running operations. The default is 0, which disables these periodic callbacks.

Cancellation: An event handler may request cancellation when an AbortCheck callback occurs. Choose an interval that is responsive without generating excessive callback traffic.

More Information and Examples
top
IgnoreMustRevalidate
IgnoreMustRevalidate As Long

Controls how cached responses containing Cache-Control: must-revalidate are handled. When 0 (the default), Chilkat revalidates such a cached response before reuse. When 1, a still-fresh cached response may be used without revalidation. This property is relevant only when FetchFromCache is 1.

Cache semantics: Ignoring must-revalidate can improve offline or high-latency operation, but it may also use content the origin server intended to be checked before reuse.

top
IgnoreNoCache
IgnoreNoCache As Long

Controls whether HTTP response directives that prohibit or restrict caching are ignored. The default is 0, which honors the server's caching instructions. When 1, Chilkat may store responses that would otherwise be excluded from the disk cache.

Use carefully: Caching content against the origin server's instructions can retain stale, private, or sensitive data. Enable this only when the application controls the content or has a specific offline-caching requirement.

top
LastBinaryResult
LastBinaryResult As Variant (read-only)

This property is mainly used in SQL Server stored procedures to retrieve binary data from the last method call that returned binary data. It is only accessible if Chilkat.Global.KeepBinaryResult is set to 1. This feature allows for the retrieval of large varbinary results in an SQL Server environment, which has restrictions on returning large data via method calls, though temp tables can handle binary properties.

top
LastErrorHtml
LastErrorHtml As String (read-only)

Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorText
LastErrorText As String (read-only)

Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorXml
LastErrorXml As String (read-only)

Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastMethodSuccess
LastMethodSuccess As Long

Indicates the success or failure of the most recent method call: 1 means success, 0 means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.

top
LastStringResult
LastStringResult As String (read-only)

In SQL Server stored procedures, this property holds the string return value of the most recent method call that returns a string. It is accessible only when Chilkat.Global.KeepStringResult is set to TRUE. SQL Server has limitations on string lengths returned from methods and properties, but temp tables can be used to access large strings.

top
LastStringResultLen
LastStringResultLen As Long (read-only)

The length, in characters, of the string contained in the LastStringResult property.

top
NoScripts
NoScripts As Long

Controls script removal when creating MHT output. When 1, script content is removed. When 0 (the default), scripts may be preserved in MHT output according to the other script-related settings.

EML behavior: Scripts are always removed when generating EML or email-oriented output, regardless of this property. Email clients commonly block active scripting for security reasons.

top
NtlmAuth
NtlmAuth As Long

When 1, Chilkat uses NTLM authentication when the origin HTTP server requests authentication. The default is 0. Set WebSiteLogin, WebSitePassword, and, when required, WebSiteLoginDomain.

Origin versus proxy authentication: These credentials authenticate to the website. Proxy credentials are configured separately with ProxyLogin and ProxyPassword. Use HTTPS whenever credentials or authenticated content are transmitted.

top
NumCacheLevels
NumCacheLevels As Long

Specifies the number of directory levels used beneath each disk-cache root. The default is 0, which stores cached items directly in the root. A value of 1 distributes items among 256 subdirectories named 0 through 255. A value of 2 uses two such levels, for example 17/204. Chilkat creates the required subdirectories automatically.

Why use levels? Directory fan-out prevents very large caches from placing thousands of files in one directory, which can degrade filesystem tools and directory operations.

top
NumCacheRoots
NumCacheRoots As Long (read-only)

Returns the number of disk-cache root directories currently configured through AddCacheRoot. Multiple roots allow cached items to be distributed across different directories or storage volumes.

Indexing: Cache-root indexes are zero-based. Use GetCacheRoot to retrieve a configured root by index.

top
PreferIpv6
PreferIpv6 As Long

Controls address-family preference when a hostname resolves to both IPv4 and IPv6 addresses. The default is 0, which prefers IPv4. Set to 1 to prefer IPv6.

Preference, not a requirement: This setting does not guarantee that IPv6 will be used. The selected address must still be reachable, and fallback behavior depends on the available addresses and connection results.

top
PreferMHTScripts
PreferMHTScripts As Long

Controls which content is retained when HTML contains a script together with a <noscript> alternative. When 1 (the default), the script is preferred and the <noscript> content is discarded. When 0, the script is removed and the <noscript> content is retained.

Interaction with NoScripts: NoScripts takes precedence when script removal is required. EML generation always removes scripts.

top
Proxy
Proxy As String

Specifies an HTTP proxy as hostname:port, for example proxy.example.com:8080. Leave the property empty when no explicit HTTP proxy is required.

Formatting: Supply only the proxy host and port; do not include an http:// or https:// scheme. If the proxy requires credentials, set ProxyLogin and ProxyPassword.

top
ProxyLogin
ProxyLogin As String

Specifies the username used to authenticate with the HTTP proxy configured by Proxy. Leave empty when the proxy does not require authentication.

top
ProxyPassword
ProxyPassword As String

Specifies the password used to authenticate with the HTTP proxy configured by Proxy. Leave empty when the proxy does not require authentication.

Credential handling: Treat proxy passwords as secrets and avoid writing them to diagnostic logs or persistent configuration in cleartext.

top
ReadTimeout
ReadTimeout As Long

Specifies the maximum number of seconds that an HTTP read may remain inactive while waiting for additional data. The default is 20 seconds. If data continues to arrive, a long download may run longer than this value.

Inactivity timeout: This is not a total-operation timeout. It applies when the incoming data stream stops making progress.

top
RequireSslCertVerify
RequireSslCertVerify As Long

Controls verification of the TLS server certificate for HTTPS connections. When 1, the connection is rejected if certificate verification fails, such as because the certificate is expired or its chain or signature cannot be validated. The default is 0.

Recommended for HTTPS: Enable certificate verification for production connections to prevent accepting an untrusted or invalid server certificate. Disabling verification removes an important protection against impersonation and man-in-the-middle attacks.

top
SocksHostname
SocksHostname As String

Specifies the hostname or dotted-decimal IPv4 address of the SOCKS proxy. This property is used only when SocksVersion is 4 or 5.

top
SocksPassword
SocksPassword As String

Specifies the password for SOCKS5 proxy authentication. SOCKS4 does not define password authentication, so this property is ignored when SocksVersion is 4.

top
SocksPort
SocksPort As Long

Specifies the TCP port of the SOCKS4 or SOCKS5 proxy. The default is 1080. This property is used only when SocksVersion is 4 or 5.

top
SocksUsername
SocksUsername As String

Specifies the username sent to the SOCKS4 or SOCKS5 proxy. It is used only when SocksVersion is 4 or 5. For SOCKS5, set SocksPassword when password authentication is required.

top
SocksVersion
SocksVersion As Long

Selects whether requests are routed through a SOCKS proxy.

ValueBehavior
0Do not use a SOCKS proxy. This is the default.
4Connect through a SOCKS4 proxy.
5Connect through a SOCKS5 proxy.
Required companion settings: For versions 4 and 5, set SocksHostname and SocksPort. Configure username and password properties when the proxy requires them.

top
UnpackDirect
UnpackDirect As Long
Introduced in version 9.5.0.47

Controls whether an MHT archive is extracted without rewriting the HTML or relocating related resources into the normal parts subdirectory. The default is 0.

SettingBehavior
0Related parts are written beneath the partsSubDir directory, and HTML references are rewritten to point to the extracted files.
1HTML is not rewritten. Related parts are written using their relative Content-Location paths beneath the unpack directory, and the partsSubDir argument is ignored.
Direct-unpack limitation: Direct unpacking is possible only when related MIME parts use relative-path Content-Location values. Parts whose locations are full URLs cannot be mapped directly in this mode.
Untrusted input: As with archive extraction generally, unpack untrusted MHT content only into a controlled directory and inspect the resulting paths and files before using them.

top
UnpackUseRelPaths
UnpackUseRelPaths As Long

Controls how extracted resources are referenced from the rewritten HTML produced by the normal unpacking mode. The default is 1, which uses relative paths. Set to 0 to write absolute local paths.

Portability: Relative paths keep the unpacked HTML and its resource directory movable as a unit. Absolute paths bind the HTML to the extraction location on the current computer.

top
UpdateCache
UpdateCache As Long

Controls whether successful HTTP GET responses are written to the configured disk cache. The default is 0. When 1, add at least one cache root with AddCacheRoot.

Reading and writing are separate: FetchFromCache controls cache reads. Applications may enable either setting independently or enable both for normal read-through caching.

top
UseCids
UseCids As Long

Controls how embedded resources are referenced in generated MHT and EML MIME documents. The default is 1.

SettingReference model
1Chilkat generates Content-ID values and rewrites HTML resource URLs as cid: references.
0HTML URLs remain unchanged, and each embedded MIME part receives a matching Content-Location header.
MIME background: Both models associate an HTML reference with a related MIME part. cid: references are common in HTML email, while Content-Location preserves the original URL or path.

top
UseFilename
UseFilename As Long

Controls whether Chilkat adds a filename parameter to the Content-Disposition header of each embedded resource, such as an image or style sheet. The default is 1.

MIME filename: The filename is metadata presented to MIME consumers; it is not the local path from which the resource was loaded.

top
UseIEProxy
UseIEProxy As Long

When 1, Chilkat uses the proxy configuration associated with Windows Internet Options / Internet Explorer. This setting is relevant on Windows systems.

Explicit configuration: Use Proxy when the application should specify a particular proxy directly rather than relying on the current user's Windows proxy settings.

top
UseInline
UseInline As Long

Controls whether embedded resources receive a Content-Disposition: inline header. The default is 1. When 0, Chilkat does not add the inline disposition for those resources.

Inline versus attachment: An inline disposition indicates that a related resource participates in rendering the HTML rather than being presented as a normal downloadable attachment. Actual display behavior remains controlled by the MIME reader or email client.

top
VerboseLogging
VerboseLogging As Long

If set to 1, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is 0. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.

top
Version
Version As String (read-only)

Version of the component/library, such as "10.1.0"

top
WebSiteLogin
WebSiteLogin As String

Specifies the username used when the origin website requires HTTP authentication. It is optional for public pages. For NTLM authentication, also set NtlmAuth to 1 and provide a domain when required.

top
WebSiteLoginDomain
WebSiteLoginDomain As String

Specifies the optional Windows domain used with NTLM website authentication. This property is relevant when NtlmAuth is 1.

top
WebSitePassword
WebSitePassword As String

Specifies the password used with WebSiteLogin when the origin website requires HTTP authentication.

Credential handling: Treat this value as a secret. Use HTTPS for authenticated pages and avoid exposing credentials through debug output or application logs.

top

Methods

AddCacheRoot
AddCacheRoot(dir As String)

Adds dir as a root directory for the disk cache. Call this method once for each cache location the application wants Chilkat to use. Multiple roots may be placed on different directories or storage volumes.

Enabling cache use: Adding a root defines storage locations but does not by itself read or write cached content. Use FetchFromCache and UpdateCache to enable cache reads and writes.
top
AddCustomHeader
AddCustomHeader(name As String, value As String)

Adds an HTTP request header to the requests sent while retrieving web pages and related resources. name is the header field name and value is its value. Call the method once for each custom header to add.

Header syntax: Pass a field name such as Authorization or X-Custom-Header without a trailing colon. Custom headers remain configured until removed with RemoveCustomHeader or cleared with ClearCustomHeaders.
Sensitive headers: A custom header may be sent for the main page and dependent-resource requests. Avoid adding credentials or tokens unless they are appropriate for every destination the conversion may contact.
top
AddExternalStyleSheet
AddExternalStyleSheet(url As String)

Adds the style sheet at url to the set of external CSS resources downloaded and embedded during conversion. This is normally unnecessary because Chilkat automatically discovers style sheets referenced directly by the HTML.

When to use it: Call this method when JavaScript or application logic constructs a style-sheet URL dynamically and the reference is therefore not visible in the static HTML that Chilkat analyzes.
top
ClearCustomHeaders
ClearCustomHeaders()

Removes all HTTP request headers previously added with AddCustomHeader. Built-in and automatically generated HTTP headers are not described as custom headers and are not the purpose of this method.

top
ExcludeImagesMatching
ExcludeImagesMatching(pattern As String)

Adds pattern as an exclusion pattern for image URLs. Images whose URLs match an exclusion pattern are not embedded in the generated MHT or EML output.

Typical use: CSS files sometimes reference decorative or conditional images that are never displayed but would otherwise become related MIME parts or apparent email attachments. Excluding those URLs can keep the generated document smaller and cleaner.
top
GetAndSaveEML
GetAndSaveEML(url_or_htmlFilepath As String, emlPath As String) As Long

Creates an EML email message from the web-page URL or local HTML file specified by url_or_htmlFilepath and saves it to emlPath. Referenced images and style sheets are fetched and embedded as related MIME parts.

EML output: Scripts are removed from EML output. emlPath is the destination EML file path; the method returns 1 on success and 0 on failure.

Returns 1 for success, 0 for failure.

top
GetAndSaveEMLAsync (1) (2) (AutoIt) (PowerBuilder) (VBScript) (Visual Basic 6.0) (Visual FoxPro)
GetAndSaveEMLAsync(url_or_htmlFilepath As String, emlPath As String) As ChilkatTask

Creates an asynchronous task to call the GetAndSaveEML method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns Nothing on failure

top
GetAndSaveMHT
GetAndSaveMHT(url_or_htmlFilepath As String, mhtPath As String) As Long

Creates an MHT web archive from the web-page URL or local HTML file specified by url_or_htmlFilepath and saves it to mhtPath. Referenced resources are fetched and embedded according to the current MHT properties.

Source and destination: url_or_htmlFilepath is either an HTTP/HTTPS URL or a local HTML file path. mhtPath is the destination MHT file path. Script handling is controlled by NoScripts and PreferMHTScripts.

Returns 1 for success, 0 for failure.

top
GetAndSaveMHTAsync (1) (2) (AutoIt) (PowerBuilder) (VBScript) (Visual Basic 6.0) (Visual FoxPro)
GetAndSaveMHTAsync(url_or_htmlFilepath As String, mhtPath As String) As ChilkatTask

Creates an asynchronous task to call the GetAndSaveMHT method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns Nothing on failure

top
GetAndZipEML
GetAndZipEML(url_or_htmlFilepath As String, zipEntryFilename As String, zipFilename As String) As Long

Creates EML output from the web-page URL or local HTML file in url_or_htmlFilepath and stores it as zipEntryFilename inside the ZIP archive named by zipFilename. The ZIP file is created when it does not exist; otherwise the new entry is appended to the existing archive.

Argument order: url_or_htmlFilepath is the source URL or HTML file, zipEntryFilename is the filename of the entry inside the ZIP, and zipFilename is the ZIP file on disk. Images and style sheets are embedded in the EML, and scripts are removed.

Returns 1 for success, 0 for failure.

top
GetAndZipEMLAsync (1) (2) (AutoIt) (PowerBuilder) (VBScript) (Visual Basic 6.0) (Visual FoxPro)
GetAndZipEMLAsync(url_or_htmlFilepath As String, zipEntryFilename As String, zipFilename As String) As ChilkatTask

Creates an asynchronous task to call the GetAndZipEML method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns Nothing on failure

top
GetAndZipMHT
GetAndZipMHT(url_or_htmlFilepath As String, zipEntryFilename As String, zipFilename As String) As Long

Creates MHT output from the web-page URL or local HTML file in url_or_htmlFilepath and stores it as zipEntryFilename inside the ZIP archive named by zipFilename. The ZIP file is created when it does not exist; otherwise the new entry is appended to the existing archive.

Argument order: url_or_htmlFilepath is the source URL or HTML file, zipEntryFilename is the filename of the entry inside the ZIP, and zipFilename is the ZIP file on disk.

Returns 1 for success, 0 for failure.

top
GetAndZipMHTAsync (1) (2) (AutoIt) (PowerBuilder) (VBScript) (Visual Basic 6.0) (Visual FoxPro)
GetAndZipMHTAsync(url_or_htmlFilepath As String, zipEntryFilename As String, zipFilename As String) As ChilkatTask

Creates an asynchronous task to call the GetAndZipMHT method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns Nothing on failure

top
GetCacheRoot
GetCacheRoot(ByVal index As Long) As String

Returns the cache-root directory at zero-based index index. Cache roots are added with AddCacheRoot, and their count is available from NumCacheRoots.

Index validation: Use an index from 0 through NumCacheRoots - 1 and check the normal method-success indicator before using the returned string.

Returns Nothing on failure

top
GetEML
GetEML(url_or_htmlFilepath As String) As String

Creates an EML MIME message from the web-page URL or local HTML file specified by url_or_htmlFilepath and returns the complete EML text in memory. Referenced images and style sheets are embedded as related MIME parts.

Memory use: The complete MIME message is returned as a string. For large pages, GetAndSaveEML avoids keeping the final EML text solely in the return value. Scripts are always removed from EML output.

Returns Nothing on failure

top
GetEMLAsync (1) (2) (AutoIt) (PowerBuilder) (VBScript) (Visual Basic 6.0) (Visual FoxPro)
GetEMLAsync(url_or_htmlFilepath As String) As ChilkatTask

Creates an asynchronous task to call the GetEML method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns Nothing on failure

top
GetMHT
GetMHT(url_or_htmlFilepath As String) As String

Creates an MHT web archive from the web-page URL or local HTML file specified by url_or_htmlFilepath and returns the complete MHT MIME text in memory. Referenced resources are embedded according to the current property settings.

Memory use: The complete archive is returned as a string. For large pages, GetAndSaveMHT writes the result directly to a file.

Returns Nothing on failure

top
GetMHTAsync (1) (2) (AutoIt) (PowerBuilder) (VBScript) (Visual Basic 6.0) (Visual FoxPro)
GetMHTAsync(url_or_htmlFilepath As String) As ChilkatTask

Creates an asynchronous task to call the GetMHT method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns Nothing on failure

top
HtmlToEML
HtmlToEML(htmlText As String) As String

Creates an EML MIME message from the in-memory HTML string in htmlText and returns the complete EML text. External images and style sheets referenced by the HTML are fetched and embedded.

Resolving relative URLs: Set BaseUrl when the HTML contains relative resource references. Scripts are removed from EML output.

Returns Nothing on failure

top
HtmlToEMLAsync (1) (2) (AutoIt) (PowerBuilder) (VBScript) (Visual Basic 6.0) (Visual FoxPro)
HtmlToEMLAsync(htmlText As String) As ChilkatTask

Creates an asynchronous task to call the HtmlToEML method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns Nothing on failure

top
HtmlToEMLFile
HtmlToEMLFile(html As String, emlFilename As String) As Long

Creates an EML email message from the in-memory HTML string in html and saves it to the file path in emlFilename. External images and style sheets are fetched and embedded as related MIME parts.

Resolving relative URLs: Set BaseUrl when the HTML contains relative resource references. Scripts are removed from EML output.

Returns 1 for success, 0 for failure.

top
HtmlToEMLFileAsync (1) (2) (AutoIt) (PowerBuilder) (VBScript) (Visual Basic 6.0) (Visual FoxPro)
HtmlToEMLFileAsync(html As String, emlFilename As String) As ChilkatTask

Creates an asynchronous task to call the HtmlToEMLFile method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns Nothing on failure

top
HtmlToMHT
HtmlToMHT(htmlText As String) As String

Creates an MHT web archive from the in-memory HTML string in htmlText and returns the complete MHT MIME text. Related resources are fetched and embedded according to the current property settings.

Resolving relative URLs: Set BaseUrl when the HTML contains relative resource references. Script handling is controlled by NoScripts and PreferMHTScripts.

Returns Nothing on failure

top
HtmlToMHTAsync (1) (2) (AutoIt) (PowerBuilder) (VBScript) (Visual Basic 6.0) (Visual FoxPro)
HtmlToMHTAsync(htmlText As String) As ChilkatTask

Creates an asynchronous task to call the HtmlToMHT method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns Nothing on failure

top
HtmlToMHTFile
HtmlToMHTFile(html As String, mhtFilename As String) As Long

Creates an MHT web archive from the in-memory HTML string in html and saves it to the file path in mhtFilename. Related resources are fetched and embedded according to the current property settings.

Resolving relative URLs: Set BaseUrl when the HTML contains relative resource references.

Returns 1 for success, 0 for failure.

top
HtmlToMHTFileAsync (1) (2) (AutoIt) (PowerBuilder) (VBScript) (Visual Basic 6.0) (Visual FoxPro)
HtmlToMHTFileAsync(html As String, mhtFilename As String) As ChilkatTask

Creates an asynchronous task to call the HtmlToMHTFile method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns Nothing on failure

top
LoadTaskCaller
LoadTaskCaller(task As ChilkatTask) As Long
Introduced in version 9.5.0.80

Loads the calling object associated with an asynchronous Task. This method exists to support Chilkat's generated asynchronous calling infrastructure.

Normally not called directly: Application code typically creates and runs tasks through the corresponding Async methods. Use this method only when a Chilkat example or support guidance specifically requires it.

Returns 1 for success, 0 for failure.

top
RemoveCustomHeader
RemoveCustomHeader(name As String)

Removes the custom HTTP request header whose field name is given by name. The name should be supplied without a trailing colon.

HTTP field names: Header field names are case-insensitive by HTTP rules. Use ClearCustomHeaders to remove every custom header at once.
top
RestoreDefaults
RestoreDefaults()

Restores the Mht object's configurable property values to their defaults.

Method-added state: Use the dedicated management methods, such as ClearCustomHeaders, when the application also needs to remove state that was added through methods rather than properties.
top
UnpackMHT
UnpackMHT(mhtFilename As String, unpackDir As String, htmlFilename As String, partsSubDir As String) As Long

Extracts the MHT file in mhtFilename into the directory specified by unpackDir. The main HTML document is written using filename htmlFilename. In normal mode, related files are written beneath the partsSubDir subdirectory, which Chilkat creates when necessary, and the HTML is rewritten to reference those extracted files.

Unpack options: Set UnpackDirect to preserve relative Content-Location paths without rewriting HTML; in that mode partsSubDir is ignored. UnpackUseRelPaths controls relative versus absolute references in normal mode.
Untrusted archives: Extract untrusted MHT files into an isolated directory and inspect the resulting files before opening or publishing them.

Returns 1 for success, 0 for failure.

top
UnpackMHTString
UnpackMHTString(mhtString As String, unpackDir As String, htmlFilename As String, partsSubDir As String) As Long

Extracts the in-memory MHT text in mhtString. unpackDir specifies the destination directory, htmlFilename specifies the main HTML filename, and partsSubDir specifies the related-parts subdirectory used by normal unpacking. Its extraction behavior is otherwise the same as UnpackMHT.

Direct mode: When UnpackDirect is 1, partsSubDir is ignored and relative Content-Location paths are used directly beneath the unpack directory.

Returns 1 for success, 0 for failure.

top

Events

AbortCheck
AbortCheck(abort As Long)

Enables a method call to be aborted by triggering the AbortCheck event at intervals defined by the HeartbeatMs property. If HeartbeatMs is set to its default value of 0, no events will occur. For instance, set HeartbeatMs to 200 to trigger 5 AbortCheck events per second.

More Information and Examples

VB6 Event callback implementation:

Important: Event callbacks from asynchronous method calls are generally not possible from the ActiveX. See VB6 Event Callbacks

Dim WithEvents myMht As ChilkatMht

Private Sub myMht_AbortCheck(abort As Long)

	'Insert application code here.

End Sub
top
PercentDone
PercentDone(ByVal pctDone As Long, abort As Long)

This provides the percentage completion for any method involving network communications or time-consuming processing, assuming the progress can be measured as a percentage. This event is triggered only when it's possible and logical to express the operation's progress as a percentage. The pctDone argument will range from 1 to 100. For methods that finish quickly, the number of PercentDone callbacks may vary, but the final callback will have pctDone equal to 100. For longer operations, callbacks will not exceed one per percentage point (e.g., 1, 2, 3, ..., 98, 99, 100).

The PercentDone callback also acts as an AbortCheck event. For fast methods where PercentDone fires, an AbortCheck event may not trigger since the PercentDone callback already provides an opportunity to abort. For longer operations, where time between PercentDone callbacks is extended, AbortCheck callbacks enable more responsive operation termination.

To abort the operation, set the abort output argument to 1. This will cause the method to terminate and return a failure status or corresponding failure value.

More Information and Examples

VB6 Event callback implementation:

Important: Event callbacks from asynchronous method calls are generally not possible from the ActiveX. See VB6 Event Callbacks

Dim WithEvents myMht As ChilkatMht

Private Sub myMht_PercentDone(ByVal pctDone As Long, abort As Long)

	'Insert application code here.

End Sub
top
ProgressInfo
ProgressInfo(ByVal name As String, ByVal value As String)

This event callback provides tag name/value pairs that detail what occurs during a method call. To discover existing tag names, create code to handle the event, emit the pairs, and review them. Most tag names are self-explanatory.

Note: Some Chilkat methods don't fire any ProgressInfo events.

More Information and Examples

VB6 Event callback implementation:

Important: Event callbacks from asynchronous method calls are generally not possible from the ActiveX. See VB6 Event Callbacks

Dim WithEvents myMht As ChilkatMht

Private Sub myMht_ProgressInfo(ByVal name As String, ByVal value As String)

	'Insert application code here.

End Sub
top
TaskCompleted
TaskCompleted(task As ChilkatTask)

Called from the background thread when an asynchronous task completes.

VB6 Event callback implementation:

Important: Event callbacks from asynchronous method calls are generally not possible from the ActiveX. See VB6 Event Callbacks

Dim WithEvents myMht As ChilkatMht

Private Sub myMht_TaskCompleted(task As ChilkatTask)

	'Insert application code here.

End Sub
top