Platform SDK: Exchange 2000 Server

CreateMHTMLBody Method

[This is preliminary documentation and subject to change.]

The CreateMHTMLBody method converts the contents of an entire Web page into a MIME Encapsulation of Aggregate HTML Documents (MHTML) formatted message body.

[Visual Basic]
Sub CreateMHTMLBody(
   ByVal URL as String,
   [ByVal Flags as CdoMHTMLFlags = 0],
   [ByVal UserName as String],
   [ByVal Password as String]
)
[C++]
HRESULT CreateMHTMLBody(
   BSTR URL,
   CdoMHTMLFlags Flags=cdoSuppressNone,
   BSTR UserName,
   BSTR Password
);
[IDL]
HRESULT CreateMHTMLBody(
   [in] BSTR URL,
   [in, defaultvalue(0), optional] CdoMHTMLFlags Flags,
   [in, optional] BSTR UserName,
   [in, optional] BSTR Password
);
URL
The full path and file name of the Web page.
Flags
A bit mask of flags controlling inclusion of items from the Web page as related body parts. The flags are defined in the CdoMHTMLFlags enumeration. The default value of Flags is CdoSuppressNone.
UserName
An optional user name to use for authentication when retrieving the resource using Hypertext Transfer Protocol (HTTP). This name can be used to set the credentials for basic, digest, NTLM, and Negotiate (Kerberos) authentication packages.
Password
An optional password to use for authentication when retrieving the resource when using the Hypertext Transfer Protocol (HTTP). This password can be used to set the credentials for basic, digest, NTLM, and Negotiate (Kerberos) authentication packages.

Remarks

The CreateMHTMLBody method scans the Web page for links and attachments, and creates appropriate body parts on this message.

CreateMHTMLBody adds new body parts to the message but does not delete any previously existing ones. However, it replaces any previous contents of the HTMLBody property. In so doing, it rewrites file-reference URLs as Content-ID URLs. For example,

<IMG SRC="http://abc/xyz.gif"> 

might be rewritten as

<IMG SRC="cid:000301bd9ad5$09a6b9f8$_CDOEX"> 

The Content-ID URL uniquely references the individual body part that contains the image. For more information on Content-ID, see MIME Headers.

Use the UserName and Password parameters when you are requesting Web pages using the Hypertext Transfer Protocol (HTTP) from a server that requires client authentication. If the Web server supports only the basic or digest authentication mechanisms, these credentials must be supplied. By default the current process security context is used to authenticate when using the NTLM or Negotiate (Kerberos) security packages; however, you can specify alternate credentials with the UserName and Password parameters.

It is recommended that you create a new message before calling CreateMHTMLBody. If you do decide to reuse a message, use the IBodyParts.DeleteAll method to remove all BodyPart objects from the message.

The CreateMHTMLBody method makes use of the following fields in the http://schemas.microsoft.com/cdo/configuration/ namespace. These fields are defined in the Configuration object referenced by the IMessage.Configuration property:

Field How the Value is Used.
httpcookies If defined, these cookies are sent with the request for the resource.
urlgetlatestversion
If set to True (VARIANT_TRUE), local cached copies of the resource are bypassed and the object requests the resource directly from the Web server.
urlproxyserver
If set, the TCP/IP connection to the Web server is obtained using the specified proxy server.
urlproxybypass
If set, the object connects directly to local IP addresses and bypasses the proxy server.

After you call CreateMHTMLBody, you can add or modify body parts, set the TextBody property, and modify HTMLBody.

The CreateMHTMLBody method does case-insensitive pattern matching on the Content-Type header field when loading from a URL. If the resource specified by a URL is not found, an error is returned.

A common use for CreateMHTMLBody is sending the contents of a Web page to a messaging user. This can be useful, for example, for news or stock report services.

Example

Dim iMsg  as New CDO.Message
Dim iConf as New CDO.Configuration
Dim Flds  as ADODB.Fields
Set Flds = iConf.Fields
Flds(cdoURLProxyServer)      = "myserver:80"
Flds(cdoURLProxyBypass)      = True
Flds(cdoURLGetLatestVersion) = True
Flds.Update

With iMsg
   Set .Configuration = iConf
   .CreateMHTMLBody("http://example.microsoft.com") 
   .To      = "MyCustomer@microsoft.com" 
   .From    = "me@microsoft.com"
   .Subject = "an example mhtml message"
   .Send 
End With

See Also

http://schemas.microsoft.com/cdo/configuration/httpcookies Field

http://schemas.microsoft.com/cdo/configuration/urlgetlatestversion Field

http://schemas.microsoft.com/cdo/configuration/urlproxyserver Field

http://schemas.microsoft.com/cdo/configuration/urlproxybypass Field

CdoMHTMLFlags Enum