Topic Path: Symbol Reference > Classes > TIdAttachmentFile Class > TIdAttachmentFile Methods > PrepareTempStream Method
ContentsIndexHome
PreviousUpNext
TIdAttachmentFile.PrepareTempStream Method

Provides a stream for accessing the contents of the message part.

function PrepareTempStream: TIdStream; override;

TStream - Stream containing the contents for the message part.

PrepareTempStream is an overridden TStream function that implements the method used to obtain a stream containing data for the message part. 

PrepareTempStream is called when loading or receiving a message with file attachments. When a TIdMessage instance is received and processed using TIdMessageClient, or a descendant class, the overridden PrepareTempStream and FinishTempStream methods for the attachment are called. These methods apply to both receiving a message from a remote mail server or accessing a message from a local mail store. Essentially, loading a message and receiving a message are the same - differing only in the type of stream used to read the message contents. 

FinishTempStream is used to ensure that the temporary stream used for processing the contents of the message part is freed after reading values stored in the message part. 

PrepareTempStream ensures that the temporary stream used for processing the contents of the message part is created prior to reading values to be stored in a TIdMessage instance. 

The ProcessMessage, ReceiveHeader, and ReceiveBody methods in TIdMessageClient rely on the overridden methods. 

PrepareTempStream sets StoredPathName to a temporary file name generated using MakeTempFilename, and sets FileIsTemp to True. 

 

Warning:

 

PrepareLoadStream causes the value in FileIsTempFile to be changed to True when the file stream is created for the file name specified in StoredPathName. Setting FileIsTempFile to True will permanently delete the attachment file created when the message is freed. This behavior differs from previous versions of Indy, where the file was assumed to be permanent storage for the message part. 

Make sure all content in the message or message part has been saved prior to calling Destroy for the TIdMessage or the TIdAttachmentFile.

TIdAttachmentFile.FinishTempStream 

TIdAttachment.FinishTempStream 

TIdAttachment.PrepareTempStream 

TIdMessage.LoadFromFile 

TIdMessage.ProcessMessage 

TIdMessage.ReceiveHeader 

TIdMessage.ReceiveBody

Copyright © 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.