(SQL Server) Number of Messages in a POP3 Mailbox
Get the number of messages in a POP3 mailbox.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
-- The mailman object is used for receiving (POP3)
-- and sending (SMTP) email.
DECLARE @mailman int
-- Use "Chilkat_9_5_0.MailMan" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.MailMan', @mailman OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- Set the POP3 server's hostname
EXEC sp_OASetProperty @mailman, 'MailHost', 'pop.someMailServer.com'
-- Set the POP3 login/password.
EXEC sp_OASetProperty @mailman, 'PopUsername', 'myLogin'
EXEC sp_OASetProperty @mailman, 'PopPassword', '****'
-- Get the number of messages in the mailbox.
DECLARE @numMessages int
EXEC sp_OAMethod @mailman, 'GetMailboxCount', @numMessages OUT
PRINT @numMessages
EXEC @hr = sp_OADestroy @mailman
END
GO
|