![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Delphi DLL) Download MIME Source of Emails in IMAP MailboxDemonstrates how to download the MIME source for emails on an IMAP server. Note: This example requires Chilkat v11.0.0 or greater.
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Imap, StringBuilder; ... procedure TForm1.Button1Click(Sender: TObject); var success: Boolean; imap: HCkImap; numMessages: Integer; sbMime: HCkStringBuilder; seqNum: Integer; begin success := False; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. imap := CkImap_Create(); // Connect to an IMAP server. // Use TLS CkImap_putSsl(imap,True); CkImap_putPort(imap,993); success := CkImap_Connect(imap,'imap.example.com'); if (success = False) then begin Memo1.Lines.Add(CkImap__lastErrorText(imap)); Exit; end; // Login success := CkImap_Login(imap,'myLogin','myPassword'); if (success = False) then begin Memo1.Lines.Add(CkImap__lastErrorText(imap)); Exit; end; // Select an IMAP mailbox success := CkImap_SelectMailbox(imap,'Inbox'); if (success = False) then begin Memo1.Lines.Add(CkImap__lastErrorText(imap)); Exit; end; // The NumMessages property contains the number of messages in the selected mailbox. numMessages := CkImap_getNumMessages(imap); if (numMessages = 0) then begin Memo1.Lines.Add('No messages exist in the Inbox.'); Exit; end; sbMime := CkStringBuilder_Create(); for seqNum := 1 to numMessages do begin CkStringBuilder_Clear(sbMime); success := CkImap_FetchSingleAsMimeSb(imap,seqNum,False,sbMime); if (success = False) then begin Memo1.Lines.Add(CkImap__lastErrorText(imap)); Exit; end; // The MIME source of the downloaded email is contained in sbMime. end; // Disconnect from the IMAP server. success := CkImap_Disconnect(imap); CkImap_Dispose(imap); CkStringBuilder_Dispose(sbMime); end; |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.