MailBee.NET Objects 4.0

MimePart.Size Property

Gets the size of the MIME part content in bytes.

public int Size {get;}

Property Value

A size of the MIME part of the message in bytes.

Remarks

This size includes the lengths of the header and body sections of the MIME part of the message. If the body was mail-transfer-encoded in the message, this size will reflect the size of the MIME part BEFORE decoding. This is different from Attachment.Size value which returns the size of the attachment body section AFTER decoding. Also, Attachment.Size does not count the header section.

Example

This sample loads the message from .EML file and displays the size of all MIME parts.

[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).
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\TestMail.eml");
foreach (MimePart part in msg.MimePartTree.GetAllParts())
{
    Console.WriteLine(part.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).
Dim msg As New MailMessage
msg.LoadMessage("C:\Docs\TestMail.eml")
For Each part As MimePart In msg.MimePartTree.GetAllParts()
    Console.WriteLine(part.Size.ToString())
Next

See Also

MimePart Class | MailBee.Mime Namespace