MailBee.NET Objects 4.0

Attachment.Size Property

Gets the length of the binary content of the attachment.

public long Size {get;}

Property Value

The length of the binary content of the message attachment in bytes.

Remarks

This property contains the length of the attachment's content in decoded form (after the mail message has already been parsed and all MIME parts have been decoded from base64, quoted-printable, etc).

Example

This sample loads the message from .EML file and displays the size of each attachment's data.

[C#]
// To use the code below, import MailBee namespaces at the top of your code.
using MailBee;
using MailBee.Mime;

// The actual code (put it into a method of your class)

// Load the message from file.
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\TestMail.eml");

// For every attachment...
foreach (Attachment attach in msg.Attachments)
{
    // ...show the length of the attachment data in bytes.
    Console.WriteLine("The size is " + attach.Size.ToString());
}
[Visual Basic]
' To use the code below, import MailBee namespaces at the top of your code.
Imports MailBee
Imports MailBee.Mime

' The actual code (put it into a method of your class)

' Load the message from file.
Dim msg As New MailMessage
msg.LoadMessage("C:\Docs\TestMail.eml")

' For every attachment...
For Each attach As Attachment In msg.Attachments
    ' ...show the length of the attachment data in bytes.
    Console.WriteLine("The size is " & attach.Size.ToString())
Next

See Also

Attachment Class | MailBee.Mime Namespace | GetData