DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoEmail
Boolean iSuccess
Integer iTemp1
// 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.
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Set ComSubject Of hoEmail To "Size example"
Set ComBody Of hoEmail To "This is the body of the email."
Get ComAddStringAttachment Of hoEmail "data.txt" "Some attached content." To iSuccess
Get ComSize Of hoEmail To iTemp1
Showln "Size (bytes) = " iTemp1
End_Procedure