Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Get the Size of a POP3 Message by UIDL
See more POP3 Examples
Demonstrates the Chilkat MailMan.GetSizeByUidl method, which returns the size, in bytes, of the email on the POP3 server identified by a UIDL. The size includes the full message content, including attachments, and the method returns -1 on error. This example looks up a message's size by its UIDL.
Background: A UIDL ("unique ID listing") is POP3's stable identifier for a message — it stays the same across sessions as long as the message remains in the mailbox. Checking a message's size before downloading lets a client skip or defer very large messages, enforce size limits, or show a progress estimate. You can obtain the available UIDLs from
GetMailboxInfoXml or FetchUidls.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.MailMan;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
mailman: TMailMan;
sizeBytes: Integer;
begin
// Demonstrates the MailMan.GetSizeByUidl method, which returns the size, in bytes, of the
// email on the POP3 server identified by a UIDL. The size includes the full message
// content, including attachments. Returns -1 on error.
mailman := TMailMan.Create;
// Configure the POP3 server connection.
mailman.MailHost := 'pop.example.com';
mailman.MailPort := 995;
mailman.PopSsl := True;
mailman.PopUsername := 'user@example.com';
mailman.PopPassword := 'myPassword';
// Get the size of a specific message by its UIDL.
sizeBytes := mailman.GetSizeByUidl('0000000123abcdef');
WriteLn('Message size (bytes): ' + sizeBytes);
// Note: Explicitly connecting/authenticating is optional. Chilkat MailMan automatically
// connects and authenticates -- using the property settings above -- whenever a server
// operation requires it. Calling the explicit connect/authenticate methods can still be
// helpful to determine whether a failure occurs while connecting or while authenticating.
mailman.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.