Topic Path: Symbol Reference > Classes > TIdIMAP4 Class > TIdIMAP4 Methods > RetrievePeek Method
ContentsIndexHome
PreviousUpNext
TIdIMAP4.RetrievePeek Method

Retrieves a message from a mailbox without marking it as read on the server.

function RetrievePeek(
    const AMsgNum: Integer; 
    AMsg: TIdMessage
): Boolean;
Parameters 
Description 
AMsgNum 
Message number to retreive from the mailbox.
 
AMsg 
Stores the retrieved message headers, body, and attachments. 

Boolean - True on success.

RetrievePeek is a Boolean function that retrieves the entire contents for a message from a mailbox without marking it as read on the remote IMAP4 server. 

Please note that "Peek" versions of the IMAP4 functions do NOT set the mfSeen message flag. A new message in your inbox should not have set the mfSeen flag until you retrieve the message via a function such as Retrieve. You can, however, retrieve the message via RetrievePeek, which should not set the mfSeen flag. The situation is not so clear, however, if you retrieve the third attachment (only) of an email. All the "Peek" versions of TIdIMAP4 functions do imply that the mfSeen flag NOT be set. Be aware that IMAP4 server support for the "Peek" functionality may vary. 

RetrievePeek requires that ConnectionState contain the value csSelected, or an EIdConnectionStateError exception will be raised. 

RetrievePeek calls a protected method that sends the IMAP4 FETCH command for the message number specified in AMsgNum. RetrievePeek performs validation for the relative message number to ensure that it contains a positive non-zero value. An EIdNumberInvalid exception can be raised if the relative message number in aMsgNum is invalid. 

On successful retrieval of the RFC 822 envelope data, RetrievePeek calls ReceiveHeader and ReceiveBody to load the message contents into the TIdMessage instance specified by AMsg. All headers, message parts, and the body of the message instance are cleared prior to storing values retrieved from the remote IMAP4 server. The value of the UID and Flags properties for the message in AMsg are updated based on the values found in the IMAP4 server response. 

RetrievePeek creates an internal TIdTCPStream instance to read message parts in the serve response, and assigns event handlers for the operation using procedure stored in OnWorkBeginForPart, OnWorkForPart, and OnWorkEndForPart

RetrievePeek sets the return value to True when the IMAP4 server response contains the value IMAP_OK

Use SelectMailBox or ExamineMailBox to select a mailbox and retrieve messages or headers in Mailbox prior to calling the Retrieve or RetrievePeek methods. 

Use on of the UIDRetrieveXxx methods to retrieve message(s) using the unique identifier (UID) for a message in the selected mailbox.

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