Topic Path: Symbol Reference > Classes > TIdIMAP4 Class > TIdIMAP4 Methods > UIDRetrieveTextPeek2 Method
TIdIMAP4.UIDRetrieveTextPeek2 Method

Retrieves the text that makes up the body of a message without updating the flags for the message.

function UIDRetrieveTextPeek2(
    const AMsgUID: String; 
    var AText: string
): Boolean;
Unique identifier for the message.
destination for text representing the body of the message. 

Boolean - True on success.

UIDRetrieveTextPeek2 is a Boolean function used to retrieve a message part for the specified message that represents the body of the message. UIDRetrieveTextPeek2 is similar to UIDRetrieveTextPeek, and does not update the stored flags for the message when accessing the message or message parts in the IMAP4 mailbox. Specifically, it does not set the 'Seen' or mfSeen flag that indicates the message has been read. 

UIDRetrieveTextPeek2 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. UIDRetrieveTextPeek2 accounts for this behavior by accessing subsequent message bodies to locate the text for the message where the initial message part has a length of 0 (zero). 

UIDRetrieveTextPeek2 validates the message identifier in AMsgUID to ensure that it contains a valid value, and raises an EIdNumberInvalid exception if the requirement is not met. 

UIDRetrieveTextPeek2 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 UIDRetrieveTextPeek or UIDRetrieveTextPeek2. 

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. 

UIDRetrieveTextPeek2 captures and decodes the body lines in the IMAP4 server response, and stores the unencoded contents of the message part in the AText argument. UIDRetrieveTextPeek2 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 RetrieveTextPeek or RetrieveTextPeek2 to retrieve the body text for a message using the relative message number for the message.

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