MailBee.NET Objects 3.1

MailMessage.DateReceived Property

Gets the date and the time when the message was received by the server.

public System.DateTime DateReceived {get;}

Property Value

A DateTime value containing the date and time when the message was delivered into the mailbox (obtained from Received header) or MinValue if no Received header is available in the message. The default value is MinValue.

Remarks

For an existing message, this property value is taken from Received headers of this message. When a new message is created using MailBee or if the eixsting message does not contain any Received headers, this property will return MinValue. If the e-mail message contains several Received headers, then the most recent one will be used to obtain DateReceived value.

When downloading messages from IMAP server, it's more reliable to use Envelope.DateReceived instead. Date information is always available in an IMAP envelope while Received header may be missing in a message.

To get or set the date when the message was composed, use Date property.

Example

This sample downloads the first message from the specified POP3 account and displays the date and time when this message was received by the POP3 server.

[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.company.com", "bill", "secret", 1);

        Console.WriteLine("This message was received at " + msg.DateReceived.ToString());
    }
}
[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.company.com", "bill", "secret", 1)

        Console.WriteLine("This message was received at " & msg.DateReceived.ToString())
    End Sub
End Module

See Also

MailMessage Class | MailBee.Mime Namespace | Date