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 Full Email Given Email HeaderWhen email headers are fetched using UIDs (not sequence numbers), then the resultant email object (containing only the header) will include auto-generated ckx-imap-* header fields to record information about the uid, attachments, etc. The IMAP UID of the email will be available in the "ckx-imap-uid" header. There will also be a "ckx-imap-isUid" header field having the value "YES" or "NO". If the email header was downloaded by UID, then "ckx-imap-isUID" will contain the value "YES" and the value of the "ckx-imap-uid" header field is the IMAP UID. If the "ckx-imap-isUID" header has a value of "NO", then the "ckx-imap-uid" header field represents the sequence number. (Sequence numbers of emails on the server can change over time, depending on whether emails are deleted. UIDs must be used to ensure that the correct full email is downloaded.) The Chilkat Email object provides a GetImapUid method to return the UID from the ckx-imap-uid header. This can then be used to download the full email using the FetchSingle method. Assuming the UID is known, download a single email by UID from an IMAP mail server.
integer li_rc oleobject loo_Imap integer li_Success oleobject loo_EmailHeader oleobject loo_EmailFull integer li_Uid integer li_IsUid integer li_UidFromCkxHeader // This example requires 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("imap.someMailServer.com") 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 li_Uid = 2014 li_IsUid = 1 // Fetch only the email header loo_EmailHeader = loo_Imap.FetchSingleHeader(li_Uid,li_IsUid) if loo_Imap.LastMethodSuccess = 1 then // Now fetch the full email li_UidFromCkxHeader = loo_EmailHeader.GetImapUid() if li_UidFromCkxHeader < 0 then // Failed. destroy loo_EmailHeader Write-Debug "No ckx-imap-uid header was found." destroy loo_Imap return end if loo_EmailFull = loo_Imap.FetchSingle(li_UidFromCkxHeader,1) if loo_Imap.LastMethodSuccess = 1 then // OK, we have the full email, do whatever we want... destroy loo_EmailFull end if destroy loo_EmailHeader end if // Disconnect from the IMAP server. li_Success = loo_Imap.Disconnect() destroy loo_Imap |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.