Indy 9
|
TIdIMAP4 = class(TIdMessageClient)
The Internet Message Access Protocol, Version 4.1 (IMAP4rev1) allows a client to access and manipulate electronic mail messages on an IMAP4 server. IMAP4 permits manipulation of remote message folders, called "mailboxes", in a way that is functionally equivalent to local mailboxes.
IMAP4rev1 includes operations for creating, deleting, and renaming mailboxes; checking for new messages; permanently removing messages; setting and clearing flags; RFC 822 and MIME message parsing; searching; and selective fetching of message attributes, texts, and portions thereof. Messages in IMAP4rev1 are accessed by the use of numbers. These numbers are either message sequence numbers or unique identifiers.
IMAP4rev1 does not specify a means of posting mail; message posting is handled by a mail transfer protocol such as TIdSMTP.
The IMAP4 protocol allows the client to issue multiple commands before expecting a server response. In addition, server responses may not necessarily be received in the order in which the IMAP commands are issued on the client. Finally, IMAP4 responses differ from TCP-related response codes in both format and content. To accomodate these protocol differences, methods inherited from TIdTCPConnection are reimplemented to support the specifics or the IMAP protocol for sending commands and receiving responses.
property ConnectionState: TIdIMAP4ConnectionState;
ConnectionState can contain one the follwing TIdIMAP4ConnectionState values:
csAny permits the commands cmdCAPABILITY, cmdNOOP, and cmdLOGOUT.
csNonAuthenticated permits commands from the csAny connection state, as well as the commands cmdAUTHENTICATE and cmdLOGOUT.
csAuthenticated permits commands from the csNonAuthenticated connection state, as well as the commands cmdSELECT, cmdEXAMINE, cmdCREATE, cmdDELETE, cmdRENAME, cmdSUBSCRIBE, cmdUNSUBSCRIBE, cmdLIST, cmdLSUB, cmdSTATUS, and cmdAPPEND.
csSelected permits commands from the csAuthenticated connection state, as well as the commands cmdCHECK, cmdCLOSE, cmdEXPUNGE, cmdSEARCH, cmdFETCH, cmdSTORE, cmdCOPY, cmdUID, and the experimental/expansion commmands represented by cmdXCmd.
property MailBox: TIdMailBox;
property MailBoxSeparator: Char;
The namespace consists of an optional namespace character '#' and namespace identifier that specified the type of mailbox store, followed by one or more mailboxes. The interpretation of mailbox names is implementation-dependent. However, the case-insensitive mailbox name INBOX is a special name reserved to mean "the primary mailbox for this user on this server".
For instance, the following examples represent the default mailbox for an IMAP4 account for the user 'dsiders', and the shared NNTP mailbox for the borland.public.delphi.internet.winsock newsgroup on the server Forums.Borland.Com:
By changing the MailboxSeparator character to '.', the previous examples would contain the following:
property Password;
property Port: integer;
property RetrieveOnSelect: TIdRetrieveOnSelect;
RetrieveOnSelect is used in SelectMailBox to determine how much data should be loaded in the TIdMailbox that represents the currently selected mailbox.
rsHeaders indicates that only message headers are loaded for messages in the mailbox.
rsMessages indicates that complete messages are loaded from the mailbox.
property Username;
function AppendMsg(const AMBName: String; AMsg: TIdMessage; const AFlags: TIdMessageFlagsSet = []): Boolean;
AppendMsg constructs the flags for the message using MessageFlagSetToStr prior to calling SendCmd using the IMAP4 APPEND command. AppendMsg inspects the numeric response code in LastCmdResult, and when the value is wsOk sends the message headers and body in AMsg to the IMAP4 server.
AppendMsg returns False if an exception occurs, or the response code from the IMAP4 server is not wsOk.
function Capability(ASlCapability: TStrings): Boolean;
Use of the Capability method is not dependent on a particular value in ConnectionState, and can be used at any time during the session. It is not necessary to issue a Capability call more than once for a client connection.
Any line in ASlCapability which begins with "AUTH=" indicates that the server supports that particular authentication mechanism. Other lines in ASlCapability may refer to extensions, revisions, or amendments to the IMAP4 specification, and are not enabled for an IMAP4 session without explicit client action to invoke the capability.
function CheckMailBox: Boolean;
CheckMailBox requires that ConnectionState contain the value csSelected or an EIdConnectionStateError exception wil be raised.
CheckMailBox executes the IMAP4 CHECK command, and sets the return value to indicate if the server response in ResultNo is wsOk.
function CheckMsgSeen(const AMsgNum: Integer): Boolean;
CheckMsgSeen calls SendCmd, after incrementing the IMAP command counter, using the IMAP FETCH command with the FLAGS attribute. CheckMsgSeen returns True when the server response indicates that the flags for the message contains the TIdMessageFlag value mfSeen.
function CloseMailBox: Boolean;
procedure Connect(const ATimeout: Integer = IdTimeoutDefault); override;
Connect calls the inherited Connect method, and on successful connection, sets ConnectionState to the value csNonAuthenticated. Connect calls SendCmd using the IMAP LOGIN command and the Username and Password values specified for the account. If the login is accepted by the IMAP server, Connect sets ConnectionState to the value csAuthenticated.
If an exception occurs in Connect, Connect calls Disconnect and re-raises the exception.
function CopyMsgs(const AMsgNumList: array of Integer; const AMBName: String): Boolean;
If AMsgNumList is an empty array (length of zero), CopyMsg sets the return value to False and exits the method. CopyMsg requires that ConnectionState contain the value csSelected, or an EIdConnectionStateError exception will be raised.
CopyMsg calls the SendCmd method using the IMAP COPY command, and sets the return value to True when the response in ResultNo contains wsOk.
constructor Create(AOwner: TComponent); override;
function CreateMailBox(const AMBName: String): Boolean;
CreateMailBox requires that the value of ConnectionState contain either csAuthenticated or csSelected, or an EIdConnectionStateError exception will be raised.
CreateMailBox calls the SendCmd method using the IMAP CREATE command and the attributes specified in AMBName. CreateMsg sets the return value to True when ResultNo contains wsOk.
function DeleteMailBox(const AMBName: String): Boolean;
DeleteMailBox requires that the value of ConnectionState contain either csAuthenticated or csSelected, or an EIdConnectionStateError exception will be raised.
DeleteMailBox calls SendCmd using the IMAP DELETE Command, and sets the return value to True when ResultNo contains wsOk.
function DeleteMsgs(const AMsgNumList: array of Integer): Boolean;
destructor Destroy; override;
procedure Disconnect; override;
Disconnect calls the SendCmd method using the IMAP LOGOUT command prior to calling the inherited Disconnect method and setting ConnectionState to the value csNonAuthenticated.
procedure DoAlert(const AMsg: String);
DoAlert signals the OnAlert event handler for the current IMAP4 client instance using the value in AMsg for the alert message. Applications must assign a procedure to the OnAlert event handler to allow responding to the event notification.
function ExamineMailBox(const AMBName: String; AMB: TIdMailBox): Boolean;
ExamineMailBox requires that the value of ConnectionState contain either csAuthenticated or csSelected, or an EIdConnectionStateError exception will be raised.
ExamineMailBox calls SendCmd using the IMAP EXAMINE command. When the numeric code in LastCmdResult contains wsOk, the text values in LastCmdResult are parsed to populate the TIdMailBox instance specified AMB.
ExamineMailBox returns True on successful completion of the method, or false when the response code is not wsOk or an exception occurs.
function ExpungeMailBox: Boolean;
ExpungeMailBox calls the SendCmd method using the IMAP EXPUNGE command, and on successful completion calls the ParseExpungeResultDetails method for the selected mailbox.
ExpungeMailBox sets the return value to True when protocol response contains the value wsOk.
procedure GetInternalLineResponse(const ATag: String);
GetInternalLineResponse calls FLastCmdResult.ParseLineResponse using the values in ATag and the TStringList to prepare the response for use by the IMAP4 client. GetInternalLineResponse frees the TStringList used to capture response lines prior to exiting from the method.
procedure GetInternalResponse(const ATag: String); overload;
GetInternalResponse calls LastCmdResult.ParseResponse using the command tag in ATag and the TStringList containing response lines to prepare the response for use in the IMAP4 client. GetInternalResponse free the TStringList prior to exiting from the method.
procedure GetInternalResponse; overload;
GetInternalResponse calls LastCmdResult.ParseResponse using the command tag in ATag and the TStringList containing response lines to prepare the response for use in the IMAP4 client. GetInternalResponse free the TStringList prior to exiting from the method.
function GetLineResponse(const ATag: String; const AAllowedResponses: array of SmallInt): SmallInt;
GetLineResponse calls GetInternalLineResponse using the value specified in ATag, and sets the numeric response code in LastCmdResult to one of the integer constants wsOk, wsNo, wsBad, wsPreAuth, or wsBye. GetLineResponse can raise an EIdException exception using the message specified in RSUnrecognizedIMAP4ResponseHeader when the numeric response code is not in one of the integer constants. GetLineResponse calls CheckResponse to insure that the numeric response code is one of the allowable values specified in AAllowedResponses.
GetLineResponse calls the inherited CheckResponse method, and sets the return value to the ResultNo from CheckResponse.
function GetResponse(const ATag: String; const AAllowedResponses: array of SmallInt): SmallInt; overload; reintroduce; function GetResponse(const AAllowedResponses: array of SmallInt): SmallInt; overload; reintroduce;
GetResponse sets the numeric code in LastCmdResult to one of the IMAP4 integer constants weOk, wsBad, wsBye, wsPreAuth, wsNo. GetResponse can raise an EIdException with the message RSUnrecognizedIMAP4ResponseHeader if a response code other than the preceeding is encountered in the IMAP4 response.
GetResponse checks the the numeric response code against the allowable numeric response code(s) specified in AAllowedResponses.
function GetResponse(const ATag: String; const AAllowedResponses: array of SmallInt): SmallInt; overload; reintroduce; function GetResponse(const AAllowedResponses: array of SmallInt): SmallInt; overload; reintroduce;
GetResponse sets the numeric code in LastCmdResult to one of the IMAP4 integer constants weOk, wsBad, wsBye, wsPreAuth, wsNo. GetResponse can raise an EIdException with the message RSUnrecognizedIMAP4ResponseHeader if a response code other than the preceeding is encountered in the IMAP4 response.
GetResponse checks the the numeric response code against the allowable numeric response code(s) specified in AAllowedResponses.
procedure KeepAlive;
function ListInferiorMailBoxes(AMailBoxList: TStringList; AInferiorMailBoxList: TStringList): Boolean;
ListInferiorMailBoxes can be used when the container folder might include many child mailboxes, and the search might be time consuming. ListInferiorMailBoxes requires that the value of ConnectionState be csAuthenticated or csSelected, or an EIdConnectionStateError exception will be raised.
When AMailBoxList in unassigned (Nil), ListInferiorMailBoxes will search for child mailboxes in the currently selected mailbox using the IMAP LIST command. ListInferiorMailBoxes calls ParseListResultDetails to populate the AInferiorMailBoxList variable with the contents of CmdResultDetails including the default "INBOX".
When AMailBoxList contains valid TStrings values, ListInferiorMailBoxes retrieves the child mailbox list for each line in AMailBoxList and accumulates the parsed results in AInferiorMailBoxList.
ListInferiorMailBoxes sets the return value to True when the numeric protocol response contains wsOk.
function ListMailBoxes(AMailBoxList: TStringList): Boolean;
ListMailBoxes calls SendCmd using the IMAP LIST command for all mailboxes in the currently selected folder. ListMailBoxes calls parses the results and stores the mailboxes information in CmdResultDetails to the AMailBoxList variable.
ListMailBoxes sets the return value to True when the protocol numeric response code contains the value wsOk.
function ListSubscribedMailBoxes(AMailBoxList: TStringList): Boolean;
ListSubscribedMailBoxes requires that the ConnectionState property for the client contain either the value csAuthenticated or csSelected. When ConnectionState is not valid for the operation, an EIdConnectionStateError exception wil be raised and the return value for the method will be False. The return value will be True when the LSUB command has compeleted with the wsOk protocol response code and the list of mailboxes has been parsed in the AMailBoxList parameter.
Use SelectMailBox to activate a particular mailbox in the subscribed mailbox list.
Use UnsubscribeMailBox to remove a mailbox from the subscribed list on the IMAP4 server.
function RenameMailBox(const AOldMBName: String; const ANewMBName: String): Boolean;
Renaming the "INBOX" mailbox is permitted, and has special behavior. It moves all messages in INBOX to a new mailbox with the given name, leaving INBOX empty. If the server implementation supports inferior hierarchical names of INBOX, these are unaffected by a rename of INBOX.
RenameMailBox requires that the value of ConnectionState contain either csAuthenticated or csSelected, or an EIdConnectionStateError exception will be raised.
RenameMailBox calls SendCmd using the IMAP4 RENAME command to alter the mailbox name. RenameMailBox sets the return value to True when ResultNo contains the value wsOk.
function Retrieve(const AMsgNum: Integer; AMsg: TIdMessage): Boolean;
Retrieve send the IMAP4 FETCH command for the specified message number. On successful retrieval of the RFC 822 envelope data, Retrieve calls ReceiveHeader and ReceiveBody to load the message contents into the TIdMessage instance specified by AMsg.
Retrieve sets the return value to True when ResultNo contains the value wsOk.
function RetrieveAllEnvelopes(AMsgList: TIdMessageCollection): Boolean;
IMAP4 envelope information consists of data items that describes the envelope structure of a message and is computed by parsing RFC-822 message headers from individual messages in the IMAP4 mailbox. Fields in the envelope structure are in the following order: date, subject, from, sender, reply-to, to, cc, bcc, in-reply-to, and message-id.
Any member in an envelope structure that is not applicable is presented as an empty value. Note that the IMAP4 server MUST default the reply-to and sender fields from the from field; a client is not expected to know how to do this.
RetrieveAllEnvelopes constructs instances of TIdMessage which are assigned to collection items added to the AMsgList message collection. RetrieveAllEnvelopes requires that the ConnectionState property for the IMAP4 client contain the value csSelected, or an EIdConnectionStateError exception will be raised and the return value will be set to False.
RetrieveAllEnvelopes implements the IMAP4 FETCH command using arguments that will result in all envelope data items for the messages in the selected mailbox. The multi-line response from the IMAP4 server is captured and parsed into newly created TIdMessages instances in AMsgList collections items.
The return value for RetrieveAllEnvelopes will be True when the protocol response code from the IMAP4 server is wsOk, and the multi-line response is successfully parsed into the AMsgList collection.
Use UIDLRetrieveAllEnvelopes to retrieve envelope data for messages using their unique Identifier.
function RetrieveAllHeaders(AMsgList: TIdMessageCollection): Boolean;
RetrieveAllHeaders is used in SelectMailBox to automatically retrieve data from the selected mailbox when RetrieveOnSelect contains the value rsHeaders.
RetrieveAllHeaders requires that ConnectionState contain the value csSelected, or an EIdConnectionStateError exception will be raised.
When AMessageList is unassigned (Nil), RetrieveAllHeaders will set the return value to False and exit from the method. Otherwise, RetrieveAllHeaders will create a new message in the collection and call RetrieveHeader for each individual message number. If the headers for a given message cannot be loaded from the IMAP mailbox, the return value is set to False and additional messages are ignored.
RetrieveAllHeaders will return True when all message headers have been retrieved from the mailbox.
Use RetrieveAllMsgs to fetch both message headers and contents in a message collection.
function RetrieveAllMsgs(AMsgList: TIdMessageCollection): Boolean;
RetrieveAllMsgs is used in SelectMailBox to automatically retrieve data from the selected mailbox when RetrieveOnSelect contains the value rsMessages.
RetrieveAllMsgs requires that ConnectionState contain the value csSelected, or an EIdConnectionStateError exception will be raised.
When AMessageList is unassigned (Nil), RetrieveAllHeaders will set the return value to False and exit from the method. Otherwise, RetrieveAllMsgs will create a new message in the collection and call Retrieve for each individual message number. If the headers for given message cannot be loaded from the IMAP mailbox, the return value is set to False and additional messages are ignored.
RetrieveAllMsgs will return True when all messages have been retrieved from the mailbox.
Use RetrieveAllHeaders to fetch only message headers for the message collection.
function RetrieveEnvelope(const AMsgNum: Integer; AMsg: TIdMessage): Boolean;
RetrieveEnvelope calls SendCmd using the IMAP4 FETCH command and arguments constructed from the value in AMsgNum and the IMAP4 fetch data flags required for the operation. RetrieveEnvelope reads the multi-line response form the IMAP4 server, and verifies that the initial response matches the command issued using SendCmd. When they are the same, RetrieveEnvelope extracts the SMTP headers from the response and parses the header values in the message specified in AMsg.
function RetrieveFlags(const AMsgNum: Integer; AFlags: TIdMessageFlagsSet): Boolean;
RetrieveFlags requires that ConnectionState contain the value csSelected, or an EIdConnectionStateError exception will be raised.
RetrieveFlags calls the IMAP4 FETCH command to get flags for the specified message number. If a protocol error occurs while retrieving the flag value, RetrieveFlags sets the return value to False and exits from the method. On successful completion, RetrieveFlags processes the untagged responses in CmdResultDetails using ParseFlagString and sets the return value to True.
function RetrieveHeader(const AMsgNum: Integer; AMsg: TIdMessage): Boolean;
RetrieveHeader requires that ConnectionState contain the value csSelected, or an EIdConnectionStateError exception will be raised.
RetrieveHeader send the IMAP4 FETCH command for the specified message number to access the stored header values. RetrieveHeader insures that the untagged server response contains an RFC 822 header before calling ReceiveHeader to populate the header values in the message instance.
RetrieveHeader sets the return value to True when the numeric protocol response in LastCmdResult contains the value wsOk.
function RetrieveMailBoxSize: Integer;
RetrieveMailBoxSize requires that ConnectionState contain the value csSelected, or an EIdConnectionStateError exception will be raised. The return value for RetrieveMailBoxSize is -1 if an error occurs in the method. RetrieveMailBoxSize calls SendCMd using the IMAP4 FETCH command to get the message size for each message in the IMAP mailbox, and accumulates the total size as the return value for the method.
function RetrieveMsgSize(const AMsgNum: Integer): Integer;
RetrieveMsgSize requires that ConnectionState contain the value csSelected, or an EIdConnectionStateError exception will be raised. The return value for RetrieveMsgSize is -1 if an error occurs in the method. RetrieveMsgSize calls SendCMd using the IMAP4 FETCH command to get the message size for the specified message number in the IMAP mailbox, and sets the return value for the method.
function RetrievePeek(const AMsgNum: Integer; AMsg: TIdMessage): Boolean;
RetrievePeek requires that ConnectionState contain the value csSelected, or an EIdConnectionStateError exception wil be raised. RetrievePeek sends the IMAP4 FETCH command to retrieve data for the specified message number. RetrievePeek insures that the server response contains untagged resposnes for the desired message prior to calling ReceiveHeader and ReceiveBody to populate the message instance.
RetrievePeek sets the return value to True when the protocol reponse code contains the value wsOk.
function SearchMailBox(const ASearchInfo: array of TIdIMAP4SearchRec): Boolean;
function SelectMailBox(const AMBName: String): Boolean;
SelectMailBox requires that the value of ConnectionState contain either csAuthenticated or csSelected, or an EIdConnectionStateError exception will be raised.
SelectMailBox calls SendCmd using the IMAP4 SELECT command for the specified mailbox name. On successful completion of the command, SelectMailBox parses the multi-line response in LastCmdResult and loads the values into the MailBox specified in AMBName. SelectMailBox sets ConnectionState to the value csSelected. If the response code from SendCmd contains a value other than wsOk, the value in ConnectionState is set csAuthenticated.
SelectMailBox also calls either RetrieveAllHeaders or RetrieveAllMsgs, based on the value of RetrieveOnSelect, to populate the message list in MailBox.
SelectMailBox sets the return value for the method to True when bumeric response code in LastCmdResult contains the value wsOk.
AResponse can be an array of SmallInt values that indicate the valie responses for the command, or a single SmallInt value.
SendCmd calls WriteLn to send the values in Atag and AOut to the IMAOP4 server, and calls GetResponse to determine the server response.
function SendCmd(const ATag: string; const AOut: string; const AResponse: SmallInt = -1): SmallInt; overload; function SendCmd(const ATag: string; const AOut: string; const AResponse: array of SmallInt): SmallInt; overload;
AResponse can be an array of SmallInt values that indicate the valie responses for the command, or a single SmallInt value.
SendCmd calls WriteLn to send the values in Atag and AOut to the IMAOP4 server, and calls GetResponse to determine the server response.
function StatusMailBox(const AMBName: String; AMB: TIdMailBox; const AStatusDataItems: array of TIdIMAP4StatusDataItem): Boolean;
StatusMailBox requires that the value of ConnectionState contain either csAuthenticated or csSelected, or an EIdConnectionStateError exception will be raised.
StatusMailBox calls SendCmd using the IMAP4 STATUS command for the specified mailbox name and data items. On succesful completion, StatusMailBox calls ParseStatusResultDetails to load the values in CmdResultDetails into the Mailbox sopecified in AMB.
StatusMailBox sets the return value for the method to True when ResultNo contains the value wsOk.
function StoreFlags(const AMsgNumList: array of Integer; const AStoreMethod: TIdIMAP4StoreDataItem; const AFlags: TIdMessageFlagsSet): Boolean;
When AMsgNumList has a length of zero, the return value for the method is set to False and the method is exited. StoreFlags requires that ConnectionState contain the value csSelected, or an EIdConnectionStateError exception will be raised.
StoreFlags calls SendCmd using the IMAP4 STORE command for the specified messages and flags. StoreFlags sets the return value for the method to True when ResultNo contains the value wsOk.
function SubscribeMailBox(const AMBName: String): Boolean;
SubscribeMailBox requires that the ConnectionState for the client contain the value csAuthenticated or csSelected to perform the IMAP4 function. SubscribeMailBox can raise an EIdConnectionStateError exception with the message RSIMAP4ConnectionStateError if ConnectionState contains a value other than csAuthenticated or csSelected.
SubscribeMailBox calls SendCmd using the IMAP4 SUBSCRIBE command and the value specified in AMBName as an argument. The IMAP4 server may validate the mailbox argument in AMBName to verify that it exists. The return value for SubscribeMailBox will be True when the numeric response code from SendCmd is wsOk and an exception does not occur.
Use UnsubscribeMailBox to remove a specified mailbox from the "active" or "subscibed" list.
function UIDCheckMsgSeen(const AMsgUID: String): Boolean;
When a mailbox has been selected, UIDCheckMsgSeen performs the IMAP4 UID command with arguments needed to retrieve mailbox message flags for the message specified in AMsgUID.
The return value for UIDCheckMsgSeen is True when the IMAP4 Seen flag is present in mailbox message flags for the message, or False when the flag is not present or the protocol request returns a value other than wsOK.
function UIDDeleteMsg(const AMsgUID: String): Boolean;
function UIDRetrieve(const AMsgUID: String; AMsg: TIdMessage): Boolean;
UIDRetrieve executes the IMAP4 UID FETCH command with the arguments needed to retrieve the message identified by the valuein AMsgUID. UIDRetrieve will retrieve the RFC message headers, body, and attachments, and mailbox message flags for storage in the message instance specified by AMsg.
Use UIDRetrievePeek to retrieve a mailbox message while avoiding use of the IMAP4 Seen message flag in the iMAP4 mailbox.
function UIDRetrieveAllEnvelopes(AMsgList: TIdMessageCollection): Boolean;
IMAP4 envelope information consists of data items that describes the envelope structure of a message and is computed by parsing RFC-822 message headers from individual messages in the IMAP4 mailbox. Fields in the envelope structure are in the following order: date, subject, from, sender, reply-to, to, cc, bcc, in-reply-to, and message-id.
Any member in an envelope structure that is not applicable is presented as an empty value. Note that the IMAP4 server MUST default the reply-to and sender fields from the from field; a client is not expected to know how to do this.
UIDRetrieveAllEnvelopes constructs instances of TIdMessage which are assigned to collection items added to the AMsgList message collection. RetrieveAllEnvelopes requires that the ConnectionState property for the IMAP4 client contain the value csSelected, or an EIdConnectionStateError exception will be raised and the return value will be set to False.
UIDRetrieveAllEnvelopes requires that ConnectionState contain the value csSelected, indicating that a mailbox has been selected, or an EIdConnectionStateError exception will be raised.
UIDRetrieveAllEnvelopes executes the IMAP4 UID FETCH command using arguments to select all envelope data items from the IMAP4 mailbox by their uniqueness identifier. UIDRetrieveAllEnvelopes will retrieve the protocol results, storing parsed values in message collection items.
The return value for UIDRetrieveAllEnvelopes will be True when the protocol response code from the IMAP4 server is wsOk, and the multi-line response is successfully parsed into the AMsgList collection.
Use RetrieveAllEnvelopes to retrieve envelope data for messages using their messge number in the IMAP4 mailbox.
function UIDRetrieveAllHeaders(AMsgList: TIdMessageCollection): Boolean;
Note: UIDRetrieveAllHeaders is not implmented at this time, and always returns the value False.
function UIDRetrieveEnvelope(const AMsgUID: String; AMsg: TIdMessage): Boolean;
UIDRetrieveEnvelope implements the IMAP4 UID FETCH command using AMsgId and other arguments needed to retrieve the envelope headers for the specified message.
IMAP4 envelope information consists of data items that describe the envelope structure of a message and is computed by parsing RFC-822 message headers from individual messages in the IMAP4 mailbox. Fields in the envelope structure are in the following order: date, subject, from, sender, reply-to, to, cc, bcc, in-reply-to, and message-id. Any member in an envelope structure that is not applicable is presented as an empty value.
UIDRetrieveEnvelope requires that the ConnectionState property contain the value csSelected, or an EIdConnectionStateError exception will be raised and the return value is set to False. The return value will be True when the protocol response code is wsOk, and the multi-line response containing the envelope data fields is successfully parsed into the AMsg message instance.
function UIDRetrieveFlags(const AMsgUID: String; AFlags: TIdMessageFlagsSet): Boolean;
UIDRetrieveFlags requires that the ConnectionState property contain the value csSelected, or an EIdConnectionStateError exception will be raised and the return value will be set to False.
UIDRetrieveFlags executes the IMAP4 UID FETCH command using arguments to retrieve the flags for the message specified in AMsgID. When the protocol response code from the IMAP4 server is wsOk, the multi-line response is parsed to store flag valuein AFlags. If the server response code is not wsOk, the return value for the method is set to False.
Use UIDStoreFlags to add or remove flags for a message identified bu it's uniqueness identifier in the IMAP4 mailbox.
function UIDRetrieveHeader(const AMsgUID: String; AMsg: TIdMessage): Boolean;
UIDRetrieveHeader requires that the ConnectionState property contain the value csSelected, or an EIdConnectionStateError exception will be raised and the return value will be set to False.
UIDRetrieveHeader reads the multi-line IMAP4 protocol response, and calls ReceiveHeader toload the RFC 822 headers into the AMsg message instance. The return value for the method will be True when the protocol response code from the IMAP4 server is wsOk.
function UIDRetrieveMailBoxSize: Integer;
UIDRetrieveMailBoxSize implements the IMAP4 UID FETCH command using arguments to select the RFC message size for all messages in the mailbox. The multi-line protocol response from the IMAP4 server is parsed to determine the size of each message, and the total is assigned as the return value for the method.
Use RetrieveMailBoxSize to calculate the size of all messages in the mailbox regardless of uniqueness identifiers for messages. RetrieveMailBoxSize will include messages marked for deletion, and draft messages.
function UIDRetrieveMsgSize(const AMsgUID: String): Integer;
UIDRetrieveMsgSize implements the IMAP4 UID FETCH using AMsgID and flags need to retrieve the RFC 822 message size from the currently selected IMAP4 mailbox. When the protocol response code is wsOk, the values are parsed to determine the number of bytes required for the message in the mailbox. The return value for the method is -1 when a response code other than wsOk is received from the IMAP4 server.
Use RetrieveMsgSize to retrieve the size for a message that can be marked for deletion or saved as a draft.
function UIDRetrievePeek(const AMsgUID: String; AMsg: TIdMessage): Boolean;
UIDRetrievePeek requires that ConnectionState contain the value csSelected, or an EIdConnectionStateError exception wil be raised. RetrievePeek sends the IMAP4 UID FETCH command to retrieve data for the specified message in AMsgID. UIDRetrievePeek insures that the server response contains untagged responses for the desired message prior to calling ReceiveHeader and receiving the body to populate the message instance.
UIDRetrievePeek sets the return value to True when the protocol response code contains the value wsOk.
Use RetrievePeek to retrieve a message by it's relative message number in the IMAP4 mailbox.
Use UIDRetrieve to retrieve a message by it's uniquesness identifier, and mark the message as read in the IMAP4 mailbox.
function UIDStoreFlags(const AMsgUID: String; const AStoreMethod: TIdIMAP4StoreDataItem; const AFlags: TIdMessageFlagsSet): Boolean;
AMsgID is the uniqueness identifier for the affected message. When AMsgID is omitted, the return value for the method is set to False and exits to the calling procedure or function.
UIDStoreFlags requires the ConnectionState property to contain the value csSelected, or an EIdConnectionStateError exception is raised and the return value for the method is set to False.
UIDStoreFlags implements the IMAP4 UID STORE command using AMsgID and the directives needed to apply the flags storage methods and values specified in AStoreMethod and AFlags. The return value for the method will be True when the IMAP4 protocol reopens code is wsOk.
function UnsubscribeMailBox(const AMBName: String): Boolean;
UnsubscribeMailBox requires that the ConnectionState for the client contain the value csAuthenticated or csSelected to perform the IMAP4 function. SubscribeMailBox can raise an EIdConnectionStateError exception with the message RSIMAP4ConnectionStateError if ConnectionState contains a value other than csAuthenticated or csSelected.
UnsubscribeMailBox calls SendCmd using the IMAP4 UNSUBSCRIBE command and the value specified in AMBName as an argument. UnsubscribeMailBox returns True when the response code from the IMAP4 server is wsOk.
Use SubscribeMailBox to add a specified mailbox from the "active" or "subscibed" list.
property OnAlert: TIdAlertEvent;
Applications must assign a procedure to the OnAlert event handler to allow responding to alert messages.