Internet Direct (Indy)
Home
PreviousUpNext
TIdAttachmentMemory Class

Encapsulates a MIME-encoded attachment or inline graphic using in-memory storage.

Pascal
TIdAttachmentMemory = class(TIdAttachment);

TIdAttachmentMemory is a TIdAttachment descendant that implements a MIME-encoded attachment or inline graphic using in-memory storage for the contents of the message part. 

TIdAttachmentMemory publishes properties that provide access to memory used to store the message part using string- or stream-based access methods. 

TIdAttachmentMemory implements an internal TMemoryStream stream used to read or write the contents of the message part during transmission and receipt. 

TIdAttachmentMemory implements the abstract virtual methods from TIdAttachment needed to retrieve and store the contents of the message part using a stream. 

 

Sending a Message with In-Memory Attachments

 

For sending a message with attachments, the following abstract virtual methods are overridden and reimplemented: 

 

The Create constructor is overloaded to accept either a string or stream argument that contains the contents of the attachment. 

When a TIdMessage instance is transmitted using TIdMessageClient, or a descendant class, the overridden OpenLoadStream and CloseLoadStream in the attachment are called. 

OpenLoadStream creates a stream used for loading the contents of the message part. During transmission, values in the internal stream are encoded based on the properties specified in the message or message part in TIdMessageClient methods like SendHeader and SendBody. 

CloseLoadStream ensures that the internal stream for accessing data in the message part is reset to its initial position when all values have been read during transmission. 

 

Accessing or Receiving a message with In-Memory Attachments

 

When loading or receiving a message with in-memory attachments, the following abstract virtual are overridden and reimplemented: 

 

When a TIdMessage instance is received and processed using TIdMessageClient, or a descendant class, the overridden PrepareTempStream and FinishTempStream methods for the in-memory 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, the actions are the same - differing only in the type of stream used to read the message contents. 

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

FinishTempStream ensures that the temporary stream used for processing the contents of the message part is reset to it beginning after reading values stored in a TIdMessage instance. 

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

TIdAttachment, TIdAttachmentFile, TIdAttachmentMemory, and TIdText are used as collection items in the TIdMessageParts collection. 

Internet Direct (Indy) version 10.1.5
Copyright © 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Website http://www.indyproject.org.
Post feedback to the Indy Documentation newsgroup.