Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Get the IMAP Server Capabilities
See more IMAP Examples
Demonstrates the Chilkat Imap.Capability method, which sends the IMAP CAPABILITY command and returns the server's raw capability response. This example connects and prints the capability list. Use HasCapability to test for a specific one.
Background: Not all IMAP servers support the same features. The
CAPABILITY response is the server's advertised menu — a space-separated list of extensions such as IDLE (push notifications of new mail), MOVE, UIDPLUS, QUOTA, and the supported AUTH= mechanisms. A well-behaved client checks capabilities before relying on an optional feature, falling back gracefully when it is absent.Chilkat Pascal (Lazarus/Delphi) Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.Imap;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
imap: TImap;
capabilities: string;
begin
success := False;
// Demonstrates the Imap.Capability method, which sends the IMAP CAPABILITY command and
// returns the server's raw capability response.
imap := TImap.Create;
imap.Ssl := True;
imap.Port := 993;
success := imap.Connect('imap.example.com');
if (success = False) then
begin
WriteLn(imap.LastErrorText);
Exit;
end;
// Ask the server for its capability list.
capabilities := imap.Capability();
if (imap.LastMethodSuccess = False) then
begin
WriteLn(imap.LastErrorText);
Exit;
end;
WriteLn('Server capabilities: ' + capabilities);
// Sample output:
//
// Server capabilities: * CAPABILITY IMAP4rev1 LOGIN-REFERRALS ID ENABLE IDLE SASL-IR LITERAL+ AUTH=PLAIN AUTH=LOGIN
// aaab OK Pre-login capabilities listed, post-login capabilities have more.
success := imap.Disconnect();
if (success = False) then
begin
WriteLn(imap.LastErrorText);
Exit;
end;
imap.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.