SQL Server
SQL Server
Get the Total Size of a POP3 Mailbox
See more POP3 Examples
Demonstrates the Chilkat MailMan.GetMailboxSize method, which returns the total combined size, in bytes, of all messages currently stored in the POP3 mailbox — also known as the POP3 maildrop size. This example configures the POP3 connection and reads the total size.
Background: POP3 reports the maildrop size via its
STAT command, which returns both a message count and the aggregate byte size. Knowing the total up front is useful for estimating download time and bandwidth, or for deciding whether to fetch everything at once versus one message at a time — especially over slow links or when the mailbox is large.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Demonstrates the MailMan.GetMailboxSize method, which returns the total combined size, in
-- bytes, of all messages currently stored in the POP3 mailbox (the POP3 maildrop size).
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'
EXEC sp_OAMethod @mailman, 'GetMailboxSize', @iTmp0 OUT
PRINT 'Total mailbox size (bytes): ' + @iTmp0
-- Note: Explicitly connecting/authenticating is optional. Chilkat MailMan automatically
-- connects and authenticates -- using the property settings above -- whenever a server
-- operation requires it. Calling the explicit connect/authenticate methods can still be
-- helpful to determine whether a failure occurs while connecting or while authenticating.
EXEC @hr = sp_OADestroy @mailman
END
GO