Platform SDK: CDO for Windows 2000

BodyPart Streams

Each body part has an associated stream, different from its content stream, that is the body part serialized in MIME format. The stream is returned in an ADO Stream object that exposes an ADO _Stream interface. The body part and all child body parts below it in the MIME hierarchy are used to construct the stream. Using this mechanism, it is possible to move portions of body part hierarchies between different messages; for example, you have built a complex MIME hierarchy and you want to copy the entire hierarchy from one message to another. The simplest way to do this is to retrieve the stream for the root body part in your hierarchy and copy it into the stream of a body part in another object. When saved, the new message parses the body part content and subsequently generates the BodyPart object hierarchy for you.

To illustrate the difference between a body part's content stream and its stream, consider the following example: the stream for a body part containing the HTML portion of a message can look like the following:

Content-Type: text/html;
        charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

<html><p>Here is a simple <b>message</b>.

The content stream for the body part would be:

<html><p>Here is a simple <b>message</b>.

Another example is a multipart/mixed body part stream returned using the IBodyPart.GetStream method, not GetEncodedContentStream. (Multipart body parts do not have a content stream, but they do have a stream.)

Content-Type: multipart/alternative;
       boundary="----=_NextPart_000_0000_01BED789.F54D7C60"

This is a multi-part message in MIME format.

------=_NextPart_000_0000_01BED789.F54D7C60
Content-Type: text/plain;
        charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Here is a simple message.
------=_NextPart_000_0000_01BED789.F54D7C60
Content-Type: text/html;
         charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

<html><p>Here is a simple <b>message</b>.
------=_NextPart_000_0000_01BED789.F54D7C60--

See Also

IBodyPart.GetStream Method