VBScript
VBScript
Check the Last Known IMAP Connection State
See more IMAP Examples
Demonstrates the Chilkat Imap.IsConnected method, which returns the last known connection state without sending any data to the IMAP server. A true result does not prove that an idle connection is still usable. This example connects and reads the state.
Background:
IsConnected is a cheap, cached check — it reports what Chilkat last observed without touching the network. That makes it fast, but it can be stale: a server or firewall may have silently dropped an idle connection. When you need to be sure the connection is actually alive, send a lightweight round trip such as Noop, or use CheckConnection for a low-level socket probe.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.IsConnected method, which returns the last known connection state
' without sending data to the IMAP server. A true result does not prove that an idle
' connection is still usable.
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
' Check the last known connection state (no data is sent to the server).
connected = imap.IsConnected()
If (connected = 1) Then
outFile.WriteLine("The IMAP object believes it is connected.")
Else
outFile.WriteLine("The IMAP object is not connected.")
End If
success = imap.Disconnect()
If (success = 0) Then
outFile.WriteLine(imap.LastErrorText)
WScript.Quit
End If
outFile.Close