Internet Direct (Indy)
Home
PreviousUpNext
TIdIMAP4.RetrieveText2 Method

Retrieves the text that makes up the body of a message.

Pascal
function RetrieveText2(
    const AMsgNum: Integer; 
    var AText: string
): Boolean;
Parameters 
Description 
AMsgNum 
relative message number for the message.
 
AText 
destination for text representing the body of the message. 

Boolean - True on success.

RetrieveText2 is a Boolean function used to retrieve a message part for the specified message that represents the body of the message. RetrieveText2 uses the IMAP4 BODY[TEXT] command to access the message part that represents the body for the message. 

Please note that some IMAP4 servers do not correctly return the body text using this command. 

Some servers return the first unencoded attachment instead. Other IMAP4 servers may truncate the initial body text found in the message structure if it contains non-textual data such as binary transfer-encoded data or multipart content with the subtype mixed, digest, or parallel. 

RetrieveText2 accounts for this behavior by checking the size of the initial message part, and retrieves a subsequent message part when the size of first message part contains 0 (zero). 

RetrieveText2 validates the message number in AMsgNum to ensure that it contains a positive non-zero value, and raises an EIdNumberInvalid exception if the requirement is not met. 

RetrieveText2 requires that ConnectionState contain the value csSelected, or an EIdConnectionStateError exception will be raised. Use SelectMailBox or ExamineMailBox to select a mailbox prior to calling RetrieveText or RetrieveText2. 

The return value for the method indicates if the body text was successfully retrieved. The return value is False if a protocol error response (any value other than IMAP_OK) is received, or the number of lines in the body text cannot be determined. 

RetrieveText2 captures and decodes the body lines in the IMAP4 server response, and stores the unencoded contents of the message part in the AText argument. RetrieveText2 creates an instance of TIdTCPStream for use in capturing the body text for the message, and assigns the OnWorkForPart, OnWorkBeginForPart, and OnWorkEndForPart event handlers used to respond to work events triggered during retrieval of the message part. 

Use UIDRetrieveText of UIDRetrieveText2 to retrieve the body text for a message using the unique identifier (UID) for the message.

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.