Delphi ActiveX
Delphi ActiveX
Send an IMAP NOOP Command
See more IMAP Examples
Demonstrates the Chilkat Imap.Noop method, which sends the IMAP NOOP command and waits for the server response. It is useful for verifying that an existing authenticated connection is still responsive, and for keeping the connection alive. This example connects, logs in, and sends a NOOP.
Background: Because
NOOP makes an actual round trip to the server, a successful reply proves the connection is genuinely alive — something the cached IsConnected cannot. It doubles as a keep-alive to prevent an idle session from timing out. In IMAP, NOOP also gives the server a chance to report changes in the selected mailbox, such as newly-arrived messages.Chilkat Delphi ActiveX Downloads
var
success: Integer;
imap: TChilkatImap;
begin
success := 0;
// Demonstrates the Imap.Noop method, which sends the IMAP NOOP command and waits for the
// server response. It is useful for verifying that an existing authenticated connection is
// still responsive and for keeping the connection alive.
imap := TChilkatImap.Create(Self);
imap.Ssl := 1;
imap.Port := 993;
success := imap.Connect('imap.example.com');
if (success = 0) then
begin
Memo1.Lines.Add(imap.LastErrorText);
Exit;
end;
success := imap.Login('user@example.com','myPassword');
if (success = 0) then
begin
Memo1.Lines.Add(imap.LastErrorText);
Exit;
end;
// Send a NOOP round trip to confirm the connection is alive.
success := imap.Noop();
if (success = 0) then
begin
Memo1.Lines.Add(imap.LastErrorText);
Exit;
end;
Memo1.Lines.Add('IMAP NOOP succeeded.');
success := imap.Disconnect();
if (success = 0) then
begin
Memo1.Lines.Add(imap.LastErrorText);
Exit;
end;