PowerBuilder
PowerBuilder
End IMAP IDLE Mode
See more IMAP Examples
Demonstrates the Chilkat Imap.IdleDone method, which ends IDLE mode by sending the protocol's DONE continuation. It takes no arguments. The authenticated connection remains open and usable afterward.
Background: While IDLE is active the connection is dedicated to receiving push notifications, so any command that needs to talk to the server — fetching a message, setting a flag — must wait until IDLE ends.
IdleDone cleanly exits IDLE without dropping the login, so the same connection can immediately be reused. Calling it when IDLE is not active fails.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Imap
integer li_TimeoutMs
string ls_Updates
li_Success = 0
// Demonstrates the Imap.IdleDone method, which ends IMAP IDLE mode by sending the DONE
// continuation. It takes no arguments. The authenticated connection remains open and usable.
loo_Imap = create oleobject
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
loo_Imap.Ssl = 1
loo_Imap.Port = 993
li_Success = loo_Imap.Connect("imap.example.com")
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
li_Success = loo_Imap.Login("user@example.com","myPassword")
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
li_Success = loo_Imap.SelectMailbox("Inbox")
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
li_Success = loo_Imap.IdleStart()
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
// Check once for any updates that arrived.
li_TimeoutMs = 5000
ls_Updates = loo_Imap.IdleCheck(li_TimeoutMs)
if loo_Imap.LastMethodSuccess = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
Write-Debug ls_Updates
// End IDLE so that ordinary IMAP commands can be sent again on the same connection.
li_Success = loo_Imap.IdleDone()
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
Write-Debug "IDLE mode ended."
li_Success = loo_Imap.Disconnect()
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
destroy loo_Imap