Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Fetch Oldest/Newest IMAP EmailEmails may be downloaded by sequence number. Assuming the selected mailbox is not empty, the oldest email is at sequence number 1, and the newest email is at sequence number N. The FetchSingle method may be used to download by sequence number. Downloads: MS Windows Visual C/C++ Libraries Linux/CentOS C/C++ Libraries MAC OS X C/C++ Libraries Solaris C/C++ Libraries C++ Builder Libraries #include <C_CkImap.h> #include <C_CkEmail.h> void ChilkatSample(void) { HCkImap imap; BOOL success; long n; BOOL isUid; HCkEmail oldestEmail; HCkEmail newestEmail; imap = CkImap_Create(); // Anything unlocks the component and begins a fully-functional 30-day trial. success = CkImap_UnlockComponent(imap,"Anything for 30-day trial"); if (success != TRUE) { printf("%s\n",CkImap_lastErrorText(imap)); return; } // Connect to an IMAP server. success = CkImap_Connect(imap,"mail.testemail.net"); if (success != TRUE) { printf("%s\n",CkImap_lastErrorText(imap)); return; } // Login success = CkImap_Login(imap,"***","***"); if (success != TRUE) { printf("%s\n",CkImap_lastErrorText(imap)); return; } // Select an IMAP mailbox success = CkImap_SelectMailbox(imap,"Inbox"); if (success != TRUE) { printf("%s\n",CkImap_lastErrorText(imap)); return; } // After selecting a mailbox, the NumMessages property // contains the number of emails in the selected mailbox. n = CkImap_getNumMessages(imap); if (n > 0) { // The oldest email is always at sequence number 1. isUid = FALSE; oldestEmail = CkImap_FetchSingle(imap,1,isUid); if (!(oldestEmail == 0 )) { // Display the From and Subject printf("%s\n",CkEmail_fromAddress(oldestEmail)); printf("%s\n",CkEmail_subject(oldestEmail)); printf("--\n"); CkEmail_Dispose(oldestEmail); } // The newest email is at sequence number N: newestEmail = CkImap_FetchSingle(imap,n,isUid); if (!(newestEmail == 0 )) { // Display the From and Subject printf("%s\n",CkEmail_fromAddress(newestEmail)); printf("%s\n",CkEmail_subject(newestEmail)); CkEmail_Dispose(newestEmail); } } // Disconnect from the IMAP server. CkImap_Disconnect(imap); CkImap_Dispose(imap); } |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.