Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) 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.
integer li_rc oleobject loo_Imap integer li_Success integer n integer li_IsUid oleobject loo_OldestEmail oleobject loo_NewestEmail // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Imap = create oleobject // Use "Chilkat_9_5_0.Imap" for versions of Chilkat < 10.0.0 li_rc = loo_Imap.ConnectToNewObject("Chilkat.Imap") if li_rc < 0 then destroy loo_Imap MessageBox("Error","Connecting to COM object failed") return end if // Connect to an IMAP server. // Use TLS loo_Imap.Ssl = 1 loo_Imap.Port = 993 li_Success = loo_Imap.Connect("mail.testemail.net") if li_Success <> 1 then Write-Debug loo_Imap.LastErrorText destroy loo_Imap return end if // Login li_Success = loo_Imap.Login("***","***") if li_Success <> 1 then Write-Debug loo_Imap.LastErrorText destroy loo_Imap return end if // Select an IMAP mailbox li_Success = loo_Imap.SelectMailbox("Inbox") if li_Success <> 1 then Write-Debug loo_Imap.LastErrorText destroy loo_Imap return end if // After selecting a mailbox, the NumMessages property // contains the number of emails in the selected mailbox. n = loo_Imap.NumMessages if n > 0 then // The oldest email is always at sequence number 1. li_IsUid = 0 loo_OldestEmail = loo_Imap.FetchSingle(1,li_IsUid) if loo_Imap.LastMethodSuccess = 1 then // Display the From and Subject Write-Debug loo_OldestEmail.FromAddress Write-Debug loo_OldestEmail.Subject Write-Debug "--" destroy loo_OldestEmail end if // The newest email is at sequence number N: loo_NewestEmail = loo_Imap.FetchSingle(n,li_IsUid) if loo_Imap.LastMethodSuccess = 1 then // Display the From and Subject Write-Debug loo_NewestEmail.FromAddress Write-Debug loo_NewestEmail.Subject destroy loo_NewestEmail end if end if // Disconnect from the IMAP server. li_Success = loo_Imap.Disconnect() destroy loo_Imap |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.