VBScript
VBScript
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 VBScript Downloads
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
success = 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.
set imap = CreateObject("Chilkat.Imap")
imap.Ssl = 1
imap.Port = 993
success = imap.Connect("imap.example.com")
If (success = 0) Then
outFile.WriteLine(imap.LastErrorText)
WScript.Quit
End If
success = imap.Login("user@example.com","myPassword")
If (success = 0) Then
outFile.WriteLine(imap.LastErrorText)
WScript.Quit
End If
' Send a NOOP round trip to confirm the connection is alive.
success = imap.Noop()
If (success = 0) Then
outFile.WriteLine(imap.LastErrorText)
WScript.Quit
End If
outFile.WriteLine("IMAP NOOP succeeded.")
success = imap.Disconnect()
If (success = 0) Then
outFile.WriteLine(imap.LastErrorText)
WScript.Quit
End If
outFile.Close