Delphi ActiveX Requires Chilkat v11.0.0+
Delphi ActiveX
List Email UIDs
List the UIDs of each email in a mailbox.Chilkat Delphi ActiveX Downloads
var
success: Integer;
imap: TChilkatImap;
fetchUids: Integer;
messageSet: TMessageSet;
i: Integer;
n: Integer;
begin
success := 0;
imap := TChilkatImap.Create(Self);
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// Connect to an IMAP server.
// Use TLS
imap.Ssl := 1;
imap.Port := 993;
success := imap.Connect('MY-IMAP-DOMAIN');
if (success = 0) then
begin
Memo1.Lines.Add(imap.LastErrorText);
Exit;
end;
// Login
success := imap.Login('MY-IMAP-LOGIN','MY-IMAP-PASSWORD');
if (success = 0) then
begin
Memo1.Lines.Add(imap.LastErrorText);
Exit;
end;
// Select an IMAP mailbox
success := imap.SelectMailbox('Inbox');
if (success = 0) then
begin
Memo1.Lines.Add(imap.LastErrorText);
Exit;
end;
// Get the message IDs of all the emails in the mailbox
// We can choose to fetch UIDs or sequence numbers.
fetchUids := 1;
messageSet := TMessageSet.Create(Self);
success := imap.QueryMbx('ALL',fetchUids,messageSet.ControlInterface);
if (success = 0) then
begin
Memo1.Lines.Add(imap.LastErrorText);
Exit;
end;
i := 0;
n := messageSet.Count;
while i < n do
begin
Memo1.Lines.Add(IntToStr(messageSet.GetId(i)));
i := i + 1;
end;
// Disconnect from the IMAP server.
success := imap.Disconnect();