Perl
Perl
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 Perl Downloads
use chilkat();
# 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.
$email = chilkat::CkEmail->new();
$email->put_Subject("Size example");
$email->put_Body("This is the body of the email.");
$email->AddStringAttachment("data.txt","Some attached content.");
print "Size (bytes) = " . $email->get_Size() . "\r\n";