SQL Server
SQL Server
Get the Size of an Email in Bytes
See more Email Object Examples
Demonstrates the read-only Chilkat Email.Size property, which is the size in bytes of the email, including all parts and attachments. This value describes the email data currently present in the object. Important: it is only valid when the full email was downloaded — if only the header was retrieved, Size reflects just the header, so do not treat it as the server-reported full message size after a partial download. This example builds an email with an attachment and prints its size.
Background: An email's on-the-wire size is usually larger than the raw content it carries. Attachments and other binary parts are encoded as text (typically Base64) so they survive mail transport, and Base64 inflates data by roughly 33%. Add MIME headers and boundary markers for each part, and the byte count reported by
Size reflects this fully-assembled message — which is what actually counts against mailbox quotas and server size limits.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Demonstrates the read-only Email.Size property, which is the size in bytes of the
-- email including all parts and attachments. Note: it is only valid when the full email
-- is present; if only the header was downloaded, it reflects just the header size.
DECLARE @email int
EXEC @hr = sp_OACreate 'Chilkat.Email', @email OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
EXEC sp_OASetProperty @email, 'Subject', 'Size example'
EXEC sp_OASetProperty @email, 'Body', 'This is the body of the email.'
DECLARE @success int
EXEC sp_OAMethod @email, 'AddStringAttachment', @success OUT, 'data.txt', 'Some attached content.'
EXEC sp_OAGetProperty @email, 'Size', @iTmp0 OUT
PRINT 'Size (bytes) = ' + @iTmp0
EXEC @hr = sp_OADestroy @email
END
GO