Visual FoxPro
Visual FoxPro
Start IMAP IDLE to Monitor a Mailbox
See more IMAP Examples
Demonstrates the Chilkat Imap.IdleStart method, which sends the IMAP IDLE command to begin listening for unsolicited mailbox updates. It takes no arguments. A mailbox must first be selected, and the server must advertise the IDLE capability.
Background: IDLE is IMAP's push mechanism: instead of polling for new mail, the client tells the server "notify me when something changes," and the server pushes updates as they happen. This is what enables near-instant new-mail alerts. While IDLE is active, no other IMAP command may be sent on that connection — call
IdleDone to leave IDLE before issuing other commands.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loImap
lnSuccess = 0
* Demonstrates the Imap.IdleStart method, which sends the IMAP IDLE command to begin listening
* for unsolicited mailbox updates. It takes no arguments. A mailbox must be selected and the
* server must advertise the IDLE capability.
loImap = CreateObject('Chilkat.Imap')
loImap.Ssl = 1
loImap.Port = 993
lnSuccess = loImap.Connect("imap.example.com")
IF (lnSuccess = 0) THEN
? loImap.LastErrorText
RELEASE loImap
CANCEL
ENDIF
lnSuccess = loImap.Login("user@example.com","myPassword")
IF (lnSuccess = 0) THEN
? loImap.LastErrorText
RELEASE loImap
CANCEL
ENDIF
lnSuccess = loImap.SelectMailbox("Inbox")
IF (lnSuccess = 0) THEN
? loImap.LastErrorText
RELEASE loImap
CANCEL
ENDIF
* Enter IDLE mode to monitor the mailbox for changes (new mail, deletions, flag changes).
lnSuccess = loImap.IdleStart()
IF (lnSuccess = 0) THEN
? loImap.LastErrorText
RELEASE loImap
CANCEL
ENDIF
? "IDLE mode started."
* While IDLE is active, no other IMAP command may be sent. End IDLE before doing more work.
lnSuccess = loImap.IdleDone()
IF (lnSuccess = 0) THEN
? loImap.LastErrorText
RELEASE loImap
CANCEL
ENDIF
lnSuccess = loImap.Disconnect()
IF (lnSuccess = 0) THEN
? loImap.LastErrorText
RELEASE loImap
CANCEL
ENDIF
RELEASE loImap