GetStream Method (IMessage)

Topic Last Modified: 2006-12-01

The GetStream method returns this message in serialized (wire-transport) format in a Microsoft® ActiveX® Data Objects (ADO) Stream object.

Applies To

IMessage 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 the _Stream Interface of the object.

Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

The GetStream method returns the entire message, including its headers and content (all body parts if Multipurpose Internet Mail Extensions (MIME) formatted) as a serialized stream within a single ADO Stream object. To obtain a stream for one of a message's body parts, call that body part object's GetDecodedContentStream or GetEncodedContentStream method.

The stream returned by this method is essentially a serialized copy of the current message, as it existed when this method was invoked. All changes made to the Stream object are local, and the message itself is not updated until the stream is flushed back by calling the Flush method on the ADO Stream object.

Example


/*
 You must have the following paths in your
 INCLUDE path.
 %CommonProgramFiles%\system\ado
 %CommonProgramFiles%\microsoft shared\cdo

*/
#ifndef _CORE_EXAMPLE_HEADERS_INCLUDED
#define _CORE_EXAMPLE_HEADERS_INCLUDED
#import <msado15.dll> no_namespace
#import <cdoex.dll> no_namespace
#include <iostream.h>
#endif

void IMessage_GetStream_Example() {

   IMessagePtr Msg(__uuidof(Message));

   Msg->To      = "someone@example.com";
   Msg->From    = "another@example.com";
   Msg->Subject = "This is the subject";
   Msg->AddAttachment("c:\\myimage_e2k7.gif","","");
   // Save the message stream to disk.
   Msg->GetStream()->SaveToFile("c:\\message.eml", adSaveCreateOverWrite );

}