Topic Path: Symbol Reference > Classes > TIdIMAP4 Class > TIdIMAP4 Methods > SendCmd Method > SendCmd Method (string, array of String)
TIdIMAP4.SendCmd Method (string, array of String)

Sends an IMAP4 command to the server and checks for valid response codes.

function SendCmd(
    const AOut: string; 
    AExpectedResponses: array of String
): string; overload;
Command to be executed on the IMAP4 server.
Anticipated server reponse(s). -1 when omitted. 

String - Response received from the IMAP4 server.

SendCmd is an overloaded String function in TIdIMAP4 that allows the client to send the IMAP4 command specified in AOut to the IMAP4 server, and anticipates a response or responses as specified in AResponse. 

AResponse can be an array of SmallInt values that indicate the valie responses for the command, or a single SmallInt value. 

SendCmd ensures that any unhandled data remaining in the buffer for the client connection is read prior to writing a new command for the remote IMAP4 server. 

SendCmd calls WriteLn to send the value AOut to the IMAP4 server, and calls GetResponse to determine the server response. The return value for the method contains the initial IMAP4 server response received for the command. 

SendCmd will handle an EIdSocketError exception raised when sending the command by setting the ConnectionState property to the value csUnexpectedlyDisconnected. The exception is re-raised for subsequent error handling.

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