VB.NET Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++DelphiFoxProJavaPerlPythonRubySQL ServerVBScript

Delphi Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
RSA Encryption
S/MIME
Socket
Spider
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Byte Array
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

Type Conversion

 

Article: Understanding COM References in Delphi

Process Large POP3 Mailbox

Demonstrates how to read email from a mailbox that may contain a large number of emails (on the order of thousands of emails or more).

Download Chilkat Email ActiveX for POP3 / SMTP

uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls,
    CHILKATMAILLib2_TLB,
    CHILKATUTILLib_TLB,
    OleCtrls;

...

procedure TForm1.Button1Click(Sender: TObject);
var
mailman: TChilkatMailMan2;
success: Integer;
sa: CHILKATUTILLib_TLB.ICkStringArray;
i: Integer;
numEmails: Integer;
chunkBeginIdx: Integer;
chunkEndIdx: Integer;
saChunk: CHILKATUTILLib_TLB.ICkStringArray;
chunkStr: String;
bundle: CHILKATMAILLib2_TLB.IChilkatEmailBundle2;

begin
//  The mailman object is used for receiving (POP3)
//  and sending (SMTP) email.
mailman := TChilkatMailMan2.Create(Self);

//  Any string argument automatically begins the 30-day trial.
success := mailman.UnlockComponent('30-day trial');
if (success <> 1) then
  begin
    ShowMessage('Component unlock failed');

  end;

//  Set the POP3 server's hostname
mailman.MailHost := 'mail.chilkatsoft.com';

//  Set the POP3 login/password.
mailman.PopUsername := 'myLogin';
mailman.PopPassword := 'myPassword';

//  First, get the list of UIDLs for all emails in the mailbox.

sa := mailman.GetUidls() as CHILKATUTILLib_TLB.ICkStringArray;

numEmails := sa.Count;

//  Download the emails in chunks of 10 emails each.
chunkBeginIdx := 0;
chunkEndIdx := 9;
if (chunkEndIdx >= numEmails) then
  begin
    chunkEndIdx := numEmails - 1;
  end;

saChunk := TCkStringArray.Create(Self).ControlInterface;
while (chunkEndIdx < (numEmails - 1)) do
  begin

    //  Build a chunk of 10 UIDLs.
    saChunk.Clear();
    for i := chunkBeginIdx to chunkEndIdx do
      begin
        saChunk.Append(sa.GetString(i));
      end;

    //  Display the UIDLs in this chunk...

    chunkStr := saChunk.SaveToText();
    Memo1.Lines.Add(chunkStr);
    Memo1.Lines.Add('----' + '\r\n');

    //  Download this chunk of email from the POP3 server.

    bundle := mailman.FetchMultiple(saChunk);
    if (bundle = nil ) then
      begin
        ShowMessage(mailman.LastErrorText);

      end;

    //  Process the bundle...
    //  (your application's processing code goes here...)

    //  Get the next chunk...
    chunkBeginIdx := chunkBeginIdx + 10;
    if (chunkBeginIdx >= numEmails) then
      begin
        break;
      end;
    chunkEndIdx := chunkEndIdx + 10;
    if (chunkEndIdx >= numEmails) then
      begin
        chunkEndIdx := numEmails - 1;
      end;

  end;


end;

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2007 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Email Component · XML Parser