MailBee.NET Objects 3.1

MailMessage.Size Property

Gets the size of the message in bytes.

public int Size {get;}

Property Value

The size of the message in bytes.

Remarks

If only the message headers were received from mail server, this property contains the size of these headers, but not of the entire message. To get the size of the entire message, use SizeOnServer property.

Example

This sample downloads the message from the mail server (only the header and the first 10 lines of the body are downloaded) and checks if the message was received completely (and thus its body fits into 10 lines).

[C#]
using System;
using MailBee;
using MailBee.Pop3Mail;
using MailBee.Mime;

class Sample
{
    static void Main(string[] args)
    {
        // Download the first mail message from the specified POP3 account.
        MailMessage msg = Pop3.QuickDownloadMessage("mail.domain.com", "jdoe", "password", 1, 10);

        if (msg.Size == msg.SizeOnServer)
        {
            Console.WriteLine("The message was received completely");
        }
        else
        {
            Console.WriteLine(@"The message was not received completely
                (maybe only the message headers were received)");
        }
    }

}
[Visual Basic]
Imports System
Imports MailBee
Imports MailBee.Pop3Mail
Imports MailBee.Mime

Module Sample
    Sub Main(ByVal args As String())
        ' Download the first mail message from the specified POP3 account.
        Dim msg As MailMessage = Pop3.QuickDownloadMessage("mail.domain.com", "jdoe", "password", 1, 10)

        If msg.Size = msg.SizeOnServer Then
            Console.WriteLine("The message was received completely")
        Else
            Console.WriteLine("The message was not received completely" & _
                "(maybe only the message headers were received)")
        End If
    End Sub
End Module

See Also

MailMessage Class | MailBee.Mime Namespace | SizeOnServer