Platform SDK: Exchange 2000 Server |
The CDO COM components provide native support for MIME formatted content. As MHTML is based upon MIME, the CDO object model can be used to create MTHML formatted messages. To facilitate the easy construction of MHTML formatted messages, the IMessage interface defines two useful methods, IMessage.CreateMHTMLBody and IMessage.AddRelatedBodyPart. The CreateMHTMLBody method can construct the entire multipart/related MIME structure for you and you need only specify the URL to the page you wish to add to the message. The appropriate multipart/related body part hierarchy is automatically created, complete with the necessary body part headers for each related part. If you desire more control over constructing the MIME hierarchy itself, you can use the AddRelatedBodyPart method in conjunction with the IMessage.HTMLBody property. AddRelatedBodyPart automatically correlates the resource added as a body part to the message with the HTML that references it. This method will create the multipart/related hierarchy if required, and, depending upon your preference, associate the referenced resource in the HTML with the related body part using Content-Location or Content-ID headers.
If you wish to perform all of the steps manually, you can go about creating the multipart/related MIME hierarchy using the only the IBodyPart.Fields, IBodyPart.GetDecodedContentStream and IBodyPart.AddBodyPart methods. This approach provides the highest flexibility, but also requires the most code and understanding of the MHTML specification, as each body part must have its content stream populated with the appropriate resource, and all header fields manually set.