Sample code for 30+ languages & platforms
SQL Server

Send a POP3 NOOP Command

See more POP3 Examples

Demonstrates the Chilkat MailMan.Pop3Noop method, which sends a POP3 NOOP command to the server. NOOP does nothing except elicit a positive response, which is useful for keeping a session alive or verifying the connection is still responsive. This example begins a POP3 session and sends a NOOP.

Background: NOOP ("no operation") is a standard keep-alive across many internet protocols. Servers often drop idle connections after a timeout; sending a periodic NOOP resets that timer so a long-running session stays open. It also serves as a cheap "are you still there?" probe — a successful reply confirms the socket and the authenticated session are still healthy.

Chilkat SQL Server Downloads

SQL Server
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @success int
    SELECT @success = 0

    --  Demonstrates the MailMan.Pop3Noop method, which sends a POP3 NOOP command to the server.
    --  NOOP does nothing except elicit a positive response, which is useful for keeping a
    --  session alive or verifying the connection is still responsive.

    DECLARE @mailman int
    EXEC @hr = sp_OACreate 'Chilkat.MailMan', @mailman OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    --  Configure the POP3 server connection.
    EXEC sp_OASetProperty @mailman, 'MailHost', 'pop.example.com'
    EXEC sp_OASetProperty @mailman, 'MailPort', 995
    EXEC sp_OASetProperty @mailman, 'PopSsl', 1
    EXEC sp_OASetProperty @mailman, 'PopUsername', 'user@example.com'
    EXEC sp_OASetProperty @mailman, 'PopPassword', 'myPassword'

    --  Begin a POP3 session.

    EXEC sp_OAMethod @mailman, 'Pop3BeginSession', @success OUT
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @mailman, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @mailman
        RETURN
      END

    --  Send a NOOP to keep the session alive.
    EXEC sp_OAMethod @mailman, 'Pop3Noop', @success OUT
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @mailman, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @mailman
        RETURN
      END


    PRINT 'POP3 NOOP succeeded.'

    EXEC @hr = sp_OADestroy @mailman


END
GO