TPop3Cli.Uidl

From Overbyte
Jump to navigation Jump to search

Main page -> ICS component reference -> TPop3Cli -> Uidl

Definition

<syntaxhighlight lang="delphi"> procedure Uidl; virtual; </syntaxhighlight>

Description

Sends UIDL command to a POP3 server. The command can be issued in 2 modes - list mode and single mode. This command is valid in POP3 TRANSACTION state so you must issue it after you've successfully authenticated. To issue it in list mode set MsgNum property to 0 before calling this method. To issue it in single mode set MsgNum property to index of the message you want to get UIDL for. UIDL returns unique ID string from POP3 server that identifies a particular message. This command belongs to optional POP3 commands and may not be supported by all servers so you must prepare your code to handle eventual -ERR error response from server indicating that the command has failed or is not supported. Note though, that most servers will support this command.

<syntaxhighlight lang="delphi"> // This will issue Uidl in list mode (triggers OnUidl events) Pop3Cli.MsgNum := 0; Pop3Cli.Uidl; </syntaxhighlight>

<syntaxhighlight lang="delphi"> // This will issue Uidl in single mode for the message 1 (does not trigger OnUidl events) Pop3Cli.MsgNum := 1; Pop3Cli.Uidl; </syntaxhighlight>

If the command is issued in single mode it returns the result from POP3 server in the next LastResponse property. Also, MsgUidl will hold the unique ID string. If it is issued in list mode, LastResponse will be empty but it will trigger OnUidlBegin, OnUidlLine and OnUidlEnd events instead which you can use to appropriately handle the output from the UIDL. When the events occur, MsgNum and MsgUidl contain the appropriate values of the currently listed message that the event is generated for.

Delphi Example

For this example to work, drop a Memo, Pop3Cli and Button components on the form. Then, add OnClick event to the button and OnUidlBegin, OnUidlLine, OnUidlEnd and OnRequestDone events to the Pop3Cli component and use the following code.

C++ Example

For this example to work, drop a Memo, Pop3Cli and Button components on the form. Then, add OnClick event to the button and OnUidlBegin, OnUidlLine, OnUidlEnd and OnRequestDone events to the Pop3Cli component and use the following code.

<syntaxhighlight lang="cpp"> //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { // Clear the memo for clean output Memo1->Lines->Clear();

// Fill the following with your actual server details Pop3Cli1->Host = "pop3.yourserver.com"; Pop3Cli1->UserName = "username"; Pop3Cli1->PassWord = "password"; Pop3Cli1->Connect(); } //---------------------------------------------------------------------------