GetEncodedContentStream Method
GetEncodedContentStream Method
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
Returns the Microsoft ActiveX Data Objects (ADO) Stream object containing the body part content in encoded format.
Applies To
Type Library
Microsoft CDO for Exchange 2000 Library
DLL Implemented In
CDOEX.DLL
Syntax
[Visual Basic]Function GetEncodedContentStream
() As ADODB.Stream
[C++]HRESULT GetEncodedContentStream ( _Stream** pVal );
Parameters
- pVal
Returned reference to a _Stream object.
Return Value
Returns S_OK if successful, or an error value otherwise.
Remarks
CDO uses the current value of the ContentTransferEncoding property to determine which encoding mechanism to use to decode or encode body part contents. CDO uses the encoding specified in ContentTransferEncoding to encode the contents. Although CDO provides standard defaults for ContentTransferEncoding, it is the programmer's responsibility to have the appropriate value set before calling GetEncodedContentStream.
The Stream object returned contains a read/write copy of the current (encoded) contents of the object implementing IBodyPart. 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 Multipurpose Internet Mail Extensions (MIME) hierarchy.
To obtain the content in its decoded form, use the GetDecodedContentStream Method.
Example
[Visual Basic]
' 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.
' Clean up. Stm.Close Stm2.Close
Set Stm = Nothing Set Stm2 = Nothing
See Also
CDO BodyPart Fields and Streams
Send us your feedback about the Microsoft Exchange Server 2003 SDK.
Build: June 2007 (2007.618.1)
© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.