SQL Server
SQL Server
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 SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @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.
DECLARE @imap int
EXEC @hr = sp_OACreate 'Chilkat.Imap', @imap OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
EXEC sp_OASetProperty @imap, 'Ssl', 1
EXEC sp_OASetProperty @imap, 'Port', 993
EXEC sp_OAMethod @imap, 'Connect', @success OUT, 'imap.example.com'
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @imap, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @imap
RETURN
END
-- Check the last known connection state (no data is sent to the server).
DECLARE @connected int
EXEC sp_OAMethod @imap, 'IsConnected', @connected OUT
IF @connected = 1
BEGIN
PRINT 'The IMAP object believes it is connected.'
END
ELSE
BEGIN
PRINT 'The IMAP object is not connected.'
END
EXEC sp_OAMethod @imap, 'Disconnect', @success OUT
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @imap, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @imap
RETURN
END
EXEC @hr = sp_OADestroy @imap
END
GO