Topic Path: Symbol Reference > Classes > TIdMessage Class > TIdMessage Methods > LoadFromStream Method
TIdMessage.LoadFromStream Method

Loads message headers and message parts from an input stream.

procedure LoadFromStream(
    AStream: TIdStream; 
    const AHeadersOnly: Boolean = False
Source used to read headers and message parts.
Indicates if only headers should be loaded. Default value is False. 

LoadFromStream is a procedure that allows loading of headers and optional message parts for the TIdMessage instance from the stream identified in AStream. 

AStream is a TIdStream descendant and represents the data source that will be used read values to be stored in the message instance. AStream can be any TStream descendant suitable for use in the as the input stream in a TIdIOHandlerStream instance. 

The current position in AStream is not changed at any time during the LoadFromStream method. LoadFromStream uses the current stream position to perform the physical input operation, and leaves the stream at the position following the read operation. 

AHeadersOnly indicates if only message headers should be loaded for the message instance. When AHeadersOnly is False, the entire message including all Headers and MessageParts will be loaded from AStream. 

LoadFromStream creates an instance of TIdMessageClient, and calls TIdMessageClient.ProcessMessage to perform the physical input required to load values into the message instance. The TIdMessageClient instance is freed prior to exiting from the method. 

Both LoadFromFile and LoadFromStream are designed to handle messages written using the SaveToStream or SavedToFile methods in the Indy TIdMessage component. These methods create an encoded version of the message contents that matches the protocol tranmissions used when the message is transmitted using TIdSMTP including the message terminator characters (CRLF.CRLF). If you are trying to import .EML message files from MS Outlook Express, or another email client, make sure that the text file contains the message terminator sequence. An exception will be raised if LoadFromFile or LoadFromStream are used to load files that do not include the message terminator sequence.

Raised with the message RSIdMessageCannotLoad when the specified file name does not exist.
Raised with the message RSMsgClientUnkownMessagePartType when an unknown message part type is encountered when processing the body of a message part. 
Copyright 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.