Platform SDK: CDO for Windows 2000 |
MHTML formatting provides a simple way to send portions of a Web page or an entire Web page as a message. The message can include all of the HTML formatting, graphics, and other elements contained in the original page. You can also choose to exclude one or more types of elements from the message.
The IMessage.CreateMHTMLBody method accepts a Uniform Resource Locator (URL) parameter and a flags parameter. The URL specifies the Web page, and the optional flags specify the types of elements to exclude when downloading the page. When successfully completed, the page comprises the HTML formatted body of the message, and each graphic or other element referenced but not excluded in included as a MIME body part. By default, the text version (IMessage.TextBody) of the message is also automatically generated fro the HTML version (IMessage.HTMLBody) of the message.
The specified source URL must be accessible to create the message. If a proxy server is required to reach a URL outside a firewall, set this location for the http://schemas.microsoft.com/cdo/configuration/urlproxyserver field in the Configuration object associated with the Message object.
The following example shows how to create a message from a Web page.
' Reference to Microsoft ActiveX Data Objects 2.5 Library ' Reference to Microsoft CDO for Windows 2000 Library Dim iMsg as New CDO.Message Dim iConf as New CDO.Configuration Dim Flds as ADODB.Fields Set Flds = iConf.Fields Flds("http://schemas.microsoft.com/cdo/configuration/urlproxyserver") = "proxyname:80" Flds("http://schemas.microsoft.com/cdo/configuration/urlproxybypass") = "<local>" Flds("http://schemas.microsoft.com/cdo/configuration/urlgetlatestversion") = True Flds.Update Set iMsg.Configuration = iConf iMsg.CreateMHTMLBody "http://example.microsoft.com", _ cdoSuppressAll, _ "domain\username", _ "password" ' ...
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace #import <cdosys.dll> no_namespace // ... IMessagePtr iMsg(__uuidof(Message)); IConfigurationPtr iConf(__uuidof(Configuration)); FieldsPtr Flds; Flds = iConf->Fields; Flds->Item["http://schemas.microsoft.com/cdo/configuration/urlproxyserver"]->Value = _variant_t("myproxyserver:80"); Flds->Item["http://schemas.microsoft.com/cdo/configuration/urlproxybypass"]->Value = _variant_t("<local>"); Flds->Item["http://schemas.microsoft.com/cdo/configuration/urlgetlatestversion"]->Value = _variant_t(VARIANT_TRUE); Flds->Update(); iMsg->Configuration = iConf; try { iMsg->CreateMHTMLBody( "http://example.microsoft.com", cdoSuppressAll, "domain\\username", "password"); } catch(_com_error err) { // handle exception }
Const g_Debug = True Dim iMsg Dim iConf Dim Flds Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") Set Flds = iConf.Fields Flds("http://schemas.microsoft.com/cdo/configuration/urlproxyserver") = "proxyname:80" Flds("http://schemas.microsoft.com/cdo/configuration/urlproxybypass") = "<local>" Flds("http://schemas.microsoft.com/cdo/configuration/urlgetlatestversion") = True Flds.Update Set iMsg.Configuration = iConf On Error Resume Next iMsg.CreateMHTMLBody "http://www.microsoft.com", cdoSuppressAll If Err.Number <> 0 Then ' Handle error. End If If g_Debug Then MsgBox iMsg.GetStream.ReadText End if
Note To suppress multiple elements, add the values of the flag constants; for example, to suppress images and style sheets, specify cdoSuppressImages + cdoSuppressStyleSheets in the flags parameter.
http://schemas.microsoft.com/cdo/configuration/urlproxyserver Field