Sample code for 30+ languages & platforms
Visual FoxPro

Send an IMAP NOOP Command

See more IMAP Examples

Demonstrates the Chilkat Imap.Noop method, which sends the IMAP NOOP command and waits for the server response. It is useful for verifying that an existing authenticated connection is still responsive, and for keeping the connection alive. This example connects, logs in, and sends a NOOP.

Background: Because NOOP makes an actual round trip to the server, a successful reply proves the connection is genuinely alive — something the cached IsConnected cannot. It doubles as a keep-alive to prevent an idle session from timing out. In IMAP, NOOP also gives the server a chance to report changes in the selected mailbox, such as newly-arrived messages.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loImap

lnSuccess = 0

*  Demonstrates the Imap.Noop method, which sends the IMAP NOOP command and waits for the
*  server response.  It is useful for verifying that an existing authenticated connection is
*  still responsive and for keeping the connection alive.

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

*  Send a NOOP round trip to confirm the connection is alive.
lnSuccess = loImap.Noop()
IF (lnSuccess = 0) THEN
    ? loImap.LastErrorText
    RELEASE loImap
    CANCEL
ENDIF

? "IMAP NOOP succeeded."

lnSuccess = loImap.Disconnect()
IF (lnSuccess = 0) THEN
    ? loImap.LastErrorText
    RELEASE loImap
    CANCEL
ENDIF

RELEASE loImap