SQL Server
SQL Server
IMAP using HTTP Proxy
Demonstrates how to connect to an IMAP server through an HTTP proxy.Chilkat SQL Server Downloads
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @imap int
EXEC @hr = sp_OACreate 'Chilkat.Imap', @imap OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- To connect through an HTTP proxy, set the HttpProxyHostname
-- and HttpProxyPort properties to the hostname (or IP address)
-- and port of the HTTP proxy. Typical port numbers used by
-- HTTP proxy servers are 3128 and 8080.
EXEC sp_OASetProperty @imap, 'HttpProxyHostname', 'www.myhttpproxy.com'
EXEC sp_OASetProperty @imap, 'HttpProxyPort', 3128
-- Important: Your HTTP proxy server must allow non-HTTP
-- traffic to pass. Otherwise this does not work.
-- Connect to an IMAP server through the HTTP proxy.
-- Use TLS
EXEC sp_OASetProperty @imap, 'Ssl', 1
EXEC sp_OASetProperty @imap, 'Port', 993
EXEC sp_OAMethod @imap, 'Connect', @success OUT, 'imap.example.com'
IF @success <> 1
BEGIN
EXEC sp_OAGetProperty @imap, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @imap
RETURN
END
-- ...
-- ..
EXEC @hr = sp_OADestroy @imap
END
GO