Sample code for 30+ languages & platforms
Delphi DLL

Check the Last Known IMAP Connection State

See more IMAP Examples

Demonstrates the Chilkat Imap.IsConnected method, which returns the last known connection state without sending any data to the IMAP server. A true result does not prove that an idle connection is still usable. This example connects and reads the state.

Background: IsConnected is a cheap, cached check — it reports what Chilkat last observed without touching the network. That makes it fast, but it can be stale: a server or firewall may have silently dropped an idle connection. When you need to be sure the connection is actually alive, send a lightweight round trip such as Noop, or use CheckConnection for a low-level socket probe.

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
imap: HCkImap;
connected: Boolean;

begin
success := False;

//  Demonstrates the Imap.IsConnected method, which returns the last known connection state
//  without sending data to the IMAP server.  A true result does not prove that an idle
//  connection is still usable.

imap := CkImap_Create();

CkImap_putSsl(imap,True);
CkImap_putPort(imap,993);

success := CkImap_Connect(imap,'imap.example.com');
if (success = False) then
  begin
    Memo1.Lines.Add(CkImap__lastErrorText(imap));
    Exit;
  end;

//  Check the last known connection state (no data is sent to the server).
connected := CkImap_IsConnected(imap);
if (connected = True) then
  begin
    Memo1.Lines.Add('The IMAP object believes it is connected.');
  end
else
  begin
    Memo1.Lines.Add('The IMAP object is not connected.');
  end;

success := CkImap_Disconnect(imap);
if (success = False) then
  begin
    Memo1.Lines.Add(CkImap__lastErrorText(imap));
    Exit;
  end;

CkImap_Dispose(imap);