Platform SDK: Exchange 2000 Server

Creating MIME-Formatted Messages

[This is preliminary documentation and subject to change.]

By default, the CDO components construct message body content using Multipurpose Internet Mail Extension (MIME) encoding format. This behavior is controlled using the IMessage.MIMEFormatted property, which defaults to True. There are many ways to create the MIME content hierarchy in a message. In most cases, such as when adding an attachment or creating an MHTML message, the IMessage interface exposes methods that automatically structure the MIME content and take care of the underlying details. These methods include IMessage.AddAttachment and IMessage.CreateMHTMLBody. To add attachments to a message in UUEncoded format, you set IMessage.MIMEFormatted to False.

In many cases, you may need to construct the entire body part hierarchy, or portions of it, manually.

Objects that participate in the body part hierarchy for a message expose implementations of the IBodyPart interface. For example, each instance of the BodyPart and Message COM classes represent one body part in the hierarchy of a MIME-encoded message. Both BodyPart and Message instances expose the IBodyPart interface to facilitate manipulation of the body part's content and properties. The IBodyPart.BodyParts collection contains the child BodyPart objects for the object and is therefore used to navigate down the hierarchy of objects. To navigate up the hierarchy from an object, you use each object's IBodyPart.Parent property.

The Message object acts as the root of the MIME hierarchy. In standard object-oriented fashion, the hierarchies extend in patterns of BodyPart -> BodyParts -> BodyPart until a terminating (leaf) node in the hierarchy is reached.

When using methods such as IMessage.CreateMHTMLBody or IMessage.AddAttachment, or the HTMLBody property on the message, the MIME hierarchy is constructed automatically. You do not need to manually add the BodyPart objects that contain the various content parts.

In many cases, you may wish to manually create the BodyPart hierarchy. To do so, you can use the IBodyPart.AddBodyPart method to add child body parts to the object. Alternately, you can access the IBodyPart.BodyParts collection explicitly and use the IBodyParts.Add method to add the new body part. Both methods create a new BodyPart instance and return an object reference on the newly added object. Using this returned interface, you can then set any fields for the object using the IBodyPart.Fields collection. For body parts that hold content, you use the appropriate Stream object to populate the contents. You access the BodyPart object's Stream using either IBodyPart.GetEncodedContentStream or IBodyPart.GetDecodedContentStream.

See Also

IMessage.AddAttachment Method

IMessage.CreateMHTMLBody Method

IMessage.MIMEFormatted Property

IBodyPart.AddBodyPart Method

IBodyParts.Add Method