Topic Path: Symbol Reference > Classes > TIdIMAP4 Class > TIdIMAP4 Methods > UIDRetrievePart Method > UIDRetrievePart Method (String, string, PChar, Integer, string)
TIdIMAP4.UIDRetrievePart Method (String, string, PChar, Integer, string)

Retrieves an individual message part for a specified message stored in the remote mailbox.

function UIDRetrievePart(
    const AMsgUID: String; 
    const APartNum: string; 
    var ABuffer: PChar; 
    var ABufferLength: Integer; 
    AContentTransferEncoding: string = 'text'
): Boolean; overload;
Unique message identifier for the message.
Message part number to be retrieved.
Destination used to store the retrieved message part.
Length of the message part.
Content transfer encoding for the message part. 

Boolean - True on success.

UIDRetrievePart is an overloaded Boolean function used to retrieve an individual message part for the unique message identifier specified in aMsgUID. 

Use UIDRetrieveStructure to find the message parts available for a specific message, and the content transfer encoding used for each of the message parts. Use the message part number (the relative position of the message part) and the content transfer encoding when calling UIDRetrievePart. 

ABuffer is the storage to use for the retrieved message part after decoding the message content using the algorithm specified in AContentTransferEncoding. 

On successful retrieval of the message part, the values in ABuffer and ABufferLength are updated to reflect the message part content and length (respectively). Please note that the caller is responsible for freeing the memory allocated in ABuffer by calling FreeMem. 

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

UIDRetrievePart 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 UIDRetrievePart. 

UIDRetrievePart sends the IMAP4 FETCH command to retrieve the specified message part, and retrieves the message part content using a TIdTCPStream instance. UIDRetrievePart assigns the event handlers in OnWorkBeginForPart, OnWorkForPart, and OnWorkEndForPart to the TIdTCPStream instance to respond to work events occurring during message part retrieval. 

After retrieval of the message part, ABuffer will contains the decoded message part content and ABufferLength will contain the length of the decoded message part.

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