GetEncodedContentStream Method

GetEncodedContentStream Method

The GetEncodedContentStream method returns a Microsoft® Active X® Data Objects (ADO) Stream object that contains the body part content in encoded format.

Syntax

Function GetEncodedContentStream() as ADODB.StreamHRESULT GetEncodedContentStream(_Stream** pVal);

Parameters

  • pVal
    On successful return, a reference to an ADO Stream object.

Remarks

Microsoft Collaboration Data Objects (CDO) uses the current values of the ContentTransferEncoding property and the IMessage.MIMEFormatted property to determine which encoding mechanism to use to decode or encode the contents of the body part. If the message is to be formatted in Multipurpose Internet Mail Extensions (MIME), then the encoding set in the ContentTransferEncoding property is used to encode the contents. Although standard defaults for the ContentTransferEncoding property are provided, it is the programmer's responsibility to set the appropriate value before calling the GetEncodedContentStream method.

The Stream object returned contains a read/write copy of the current (encoded) contents of the object that is implementing the IbodyPart interface. If you modify the contents within the returned Stream object, you must call the Flush method to commit the changes back into the object.

The GetEncodedContentStream method returns an error if called on a multipart body part because these body parts have no content and simply act as structure units in the MIME hierarchy.

To obtain the content in its decoded form, use the GetDecodedContentStream method.

Example

'  This is a manual way to copy an attachment
Dim iMsg as New CDO.Message
Dim iBp as CDO.IBodyPart
Set iBp = iMsg.AddAttachment("c:\report.doc")
Dim Stm as ADODB.Stream
Set Stm = iBp.GetEncodedContentStream

Dim iMsg2 as new CDO.Message
Dim iBp2 as CDO.IBodyPart
Dim Flds as ADODB.Fields

Set iBp2 = iMsg2.BodyPart.AddBodyPart

Set Flds = iBp2.Fields
Flds("urn:schemas:mailheader:content-disposition") = "attachment"
Flds("urn:schemas:mailheader:content-transfer-encoding") = "base64"
Flds.Update

Dim Stm2 as ADODB.Stream
Set Stm2 = iBp2.GetEncodedContentStream
Stm .CopyTo Stm2
Stm2.Flush
 ' go on to send messages 

See Also

Reference

ADOStream Object

Concepts

GetDecodedContentStream Method