Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Get the IMAP UID of an Email
See more Email Object Examples
Demonstrates the Chilkat Email.GetImapUid method. When email headers are downloaded from an IMAP server using Chilkat IMAP, a ckx-imap-uid header field is added to the email, and GetImapUid returns its value. This example sets that header directly to illustrate how the method reads it.
Background: IMAP assigns each message in a mailbox a UID — a stable numeric identifier used to fetch, flag, move, or delete that specific message. Chilkat records it in the
ckx-imap-uid header so it stays attached to the downloaded Email object. This is the IMAP counterpart to POP3's UIDL (see the Uidl property), letting an application correlate a local message back to its position on the server.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.Email;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
email: TEmail;
begin
// Demonstrates the GetImapUid method. When an email is downloaded from an IMAP server
// (using Chilkat IMAP), a ckx-imap-uid header field is added, and GetImapUid returns its
// value. Here we set the header directly to show how the method reads it.
email := TEmail.Create;
email.Subject := 'GetImapUid example';
// Normally the IMAP download sets this header; we set it here for demonstration.
email.AddHeaderField('ckx-imap-uid','482');
WriteLn('IMAP UID = ' + email.GetImapUid());
email.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.