![]() |
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
(PureBasic) Fetch Full Email Given Email HeaderWhen you fetch email headers using UIDs instead of sequence numbers, the email object (which includes only the header) will have auto-generated
The Chilkat Email object offers a Note: This example requires Chilkat v11.0.0 or greater.
IncludeFile "CkEmail.pb" IncludeFile "CkImap.pb" Procedure ChilkatExample() success.i = 0 ; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. imap.i = CkImap::ckCreate() If imap.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; Connect to an IMAP server. ; Use TLS CkImap::setCkSsl(imap, 1) CkImap::setCkPort(imap, 993) success = CkImap::ckConnect(imap,"imap.example.com") If success = 0 Debug CkImap::ckLastErrorText(imap) CkImap::ckDispose(imap) ProcedureReturn EndIf ; Login success = CkImap::ckLogin(imap,"***","***") If success = 0 Debug CkImap::ckLastErrorText(imap) CkImap::ckDispose(imap) ProcedureReturn EndIf ; Select an IMAP mailbox success = CkImap::ckSelectMailbox(imap,"Inbox") If success = 0 Debug CkImap::ckLastErrorText(imap) CkImap::ckDispose(imap) ProcedureReturn EndIf emailHeader.i = CkEmail::ckCreate() If emailHeader.i = 0 Debug "Failed to create object." ProcedureReturn EndIf emailFull.i = CkEmail::ckCreate() If emailFull.i = 0 Debug "Failed to create object." ProcedureReturn EndIf uid.i = 2014 isUid.i = 1 ; Fetch only the email header success = CkImap::ckFetchEmail(imap,1,uid,isUid,emailHeader) If success = 0 Debug CkImap::ckLastErrorText(imap) CkImap::ckDispose(imap) CkEmail::ckDispose(emailHeader) CkEmail::ckDispose(emailFull) ProcedureReturn EndIf ; Now fetch the full email uidFromCkxHeader.i = CkEmail::ckGetImapUid(emailHeader) If uidFromCkxHeader < 0 ; Failed. Debug "No ckx-imap-uid header was found." CkImap::ckDispose(imap) CkEmail::ckDispose(emailHeader) CkEmail::ckDispose(emailFull) ProcedureReturn EndIf success = CkImap::ckFetchEmail(imap,0,uid,isUid,emailFull) If success = 0 Debug CkImap::ckLastErrorText(imap) CkImap::ckDispose(imap) CkEmail::ckDispose(emailHeader) CkEmail::ckDispose(emailFull) ProcedureReturn EndIf ; OK, we have the full email, do whatever we want... ; Disconnect from the IMAP server. success = CkImap::ckDisconnect(imap) CkImap::ckDispose(imap) CkEmail::ckDispose(emailHeader) CkEmail::ckDispose(emailFull) ProcedureReturn EndProcedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.