Topic Path: Symbol Reference > Classes > TIdAttachmentFile Class
ContentsIndexHome
PreviousUpNext
TIdAttachmentFile Class

Encapsulates a MIME-encoded attachment or inline graphic using local file storage.

File
TIdAttachmentFile = class(TIdAttachment);

TIdAttachmentFile is a TIdAttachment descendant that implements a MIME-encoded attachment or inline graphic using a local file for storage of the contents of the message part. 

TIdAttachmentFile publishes properties need to represent the file used as storage for the message part, and its longevity. TIdAttachmentFile also implements the internal TFileStream stream used to read or write the contents of the message part during transmission and receipt. 

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

 

Sending a Message with File Attachments

 

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

 

Create accepts an argument that indicates the file name containing 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. These overridden methods open and close the internal stream used for loading the contents of the message part during transmission. 

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 freed when all values have been read during transmission. 

 

Accessing or Receiving a message with File Attachments

 

When loading or receiving a message with file 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 file 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 created 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 freed 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. 

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