Dela via


GetStream Method (IBodyPart)

Topic Last Modified: 2006-06-13

Returns the Microsoft® ActiveX® Data Objects (ADO) Stream object reference containing the headers and content of this body part.

Applies To

IBodyPart Interface

Type Library

Microsoft CDO for Exchange 2000 Library

DLL Implemented In

CDOEX.DLL

Syntax

Function GetStream() As ADODB.Stream
HRESULT GetStream
(
        _Stream** pVal
);

Parameters

  • pVal
    Returned reference to a _Stream object.

Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

The GetStream method returns a copy of the entire body part, including its headers, content, and all subparts, in serialized (transport) form within a single Stream object. To obtain a stream containing just the body part contents, use either GetDecodedContentStream or GetEncodedContentStream.

Calling GetStream returns a copy of the contents of this BodyPart object in the returned Stream object. If you modify the content in the returned Stream object and you then want to update the location from which you retrieved the stream, you must commit the changes back by calling the Flush (_Stream.Flush) method.

Examples


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.GetStream

' This stream has mail headers and the content
' in encoded format for the report.doc attachment.

' Clean up.
Stm.Close
Set Stm = Nothing

The AddAttachment method sets up standard header fields automatically. The stream contents could look something like

Content-Type: application/msword;
        name="report.doc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
        filename="report.doc"

0M8R4KGxGuEAAAAAA....(etc)
////////////////////////////////


        

See Also

Other Resources

CDO BodyPart Fields and Streams