Export (0) Print
Expand All

CreateMHTMLBody Method

Exchange Server 2003

CreateMHTMLBody Method

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

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

Applies To

Type Library

Microsoft CDO for Exchange 2000 Library

DLL Implemented In

CDOEX.DLL

Syntax

        [Visual Basic]Sub CreateMHTMLBody
(
    ByVal URL As String,     ByVal [Flags As CdoMHTMLFlags],     ByVal [UserName As String],     ByVal [Password As String]
)

        [C++]HRESULT CreateMHTMLBody
(
    BSTR URL,
    CdoMHTMLFlags Flags,
    BSTR UserName,
    BSTR Password
);

Parameters

URL
The full path and file name of the Web page.
Flags
A bitmask of flags controlling inclusion of items from the Web page as related body parts. The flags are defined in the CdoMHTMLFlags Enum. The default value of Flags is CdoSuppressNone.
UserName
An optional user name to use for authentication when retrieving the resource using HTTP. This name can be used to set the credentials for basic, NTLM, and Negotiate (Kerberos) authentication packages.
Password
An optional password to use for authentication when retrieving the resource using HTTP. This password can be used to set the credentials for basic, NTLM, and Negotiate (Kerberos) authentication packages.

Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

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

Important  If the Web page contains <img> tags referencing files that have spaces in the file name, CDO for Exchange 2000 Server (CDOEX) will not properly add the files into the e-mail message. Image file names and other files referenced in the Web page should always be URL-encoded to ensure the files can be obtained by CDOEX.

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 about Content-ID, see MIME Headers.

Use the UserName and Password parameters when you are requesting Web pages using HTTP from a server that requires client authentication. If the Web server supports only the basic authentication mechanism, 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 alternative credentials with the UserName and Password parameters.

It is recommended that you create a new message before calling CreateMHTMLBody. If you 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 Field If defined, these cookies are sent with the request for the resource.
urlgetlatestversion Field 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 Field If set, the TCP/IP connection to the Web server is obtained using the specified proxy server.
urlproxybypass Field If set, the object connects directly to local Internet Protocol (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 non case-sensitive 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

        [Visual Basic]

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.example.com")
   .To = "MyCustomer@example.com"
   .From = "me@example.com"
   .Subject = "an example mhtml message"
   .Send
End With

See Also

httpcookies Field

urlgetlatestversion Field

urlproxyserver Field

urlproxybypass Field

CdoMHTMLFlags Enum

Show:
© 2014 Microsoft