![]()  | 
  
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
 
      (PowerBuilder) Using IMAP IDLE to Wait for UpdatesThis example demonstrates how to use the IMAP IDLE functionality in Chilkat. 
 integer li_rc oleobject loo_Imap integer li_Success string ls_IdleResultXml 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 // .... // .... // .... // 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 a mailbox has been selected, IDLE may begin. // Idling tells the IMAP server to push unsolicited updates for the selected // mailbox to the connected client (which is your application). li_Success = loo_Imap.IdleStart() if li_Success <> 1 then Write-Debug loo_Imap.LastErrorText destroy loo_Imap return end if // Once idling has started, your code still has to periodically check to see // if any updates have arrived. However, this is significantly different // then what normally occurs when checking email. The IdleCheck does NOT // send a message to the IMAP server. It simply checks the connection to see // if any data has arrived. If so, it can be consumed and the client (your app) // can react appropriately. // Note: It is recommended that idling only run for a max of 20 minutes before stopping and // re-starting the IDLE. This is to maintain a minimum low level of activity so that // the IMAP server does not disconnect (which it may do if it considers the connection to // be truly inactive, i.e. forgotten). // To check the connection for IDLE updates, call IdleCheck. The 1st argument indicates how // long we're willing to wait. We'll wait 1 millisecond: ls_IdleResultXml = loo_Imap.IdleCheck(1) if loo_Imap.LastMethodSuccess <> 1 then Write-Debug loo_Imap.LastErrorText destroy loo_Imap return end if // See the online reference documentation for details regarding the XML that is returned. // Your application code would parse the XML to determine what action to take. // If the XML contains "<idle></idle>", then no updates are available and your application // would call IdleCheck again at some point in the future. // If updates are available, the IDLE must be terminated by calling IdleDone, like this: li_Success = loo_Imap.IdleDone() if li_Success <> 1 then Write-Debug loo_Imap.LastErrorText destroy loo_Imap return end if // Once the IDLE is terminated, your application can make calls to fetch email, etc. // Any attempt to communicate with the IMAP server prior to terminating the IDLE will // result in failure. // IMPORTANT: Please realize that your application code will be structured differently than shown here. // The call to IdleCheck will likely be in a function/procedure that is periodically called // after the IdleStart has been called from some other location in your app destroy loo_Imap  | 
  ||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.