MailMessageDate Property
Gets or sets the date and the time when the mail message was composed.

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
public DateTime Date { get; set; }

Property Value

Type: DateTime
The date when the mail message was composed. The default value is MinValue.
MailBeeDateParsingExceptionA date parsing error occurred and ThrowExceptions is true.

In the case when an existing message gets parsed, the value of this property is taken from Date header.

Otherwise, if a new message is being sent or submitted to the pickup folder and SetDateOnSend property is true, Date value will be set to Now directly at the moment of sending.

On other hand, if SetDateOnSend property is set to false, the existing value of Date header will be used. If it's MinValue, Date header will not be added to the message.

When the message gets built without sending (for instance, when you save it into a file), Date value is not changed. Thus, if you did not set it manually, no Date header will present in the resulting message.

To set the date to the current date and time, you can use msg.Date=DateTime.Now (assuming msg is MailMessage instance).

You can also use SetDateFromString(String) method to set Date header value from a string.

To get the date when the message was delivered to the mailbox (rather than composed), use DateReceived property.

Note Note
By default, all dates are adjusted to local timezone. To adjust to GMT (UTC) time, set DatesAsUtc property of Parser object to true.

Reading this property by default won't allow out-of-range values in Date header (for instance, 79 seconds while 59 is the maximum for a valid value). You can, however, enable FixBadDates to let MailBee tolerate some not significant errors (can be useful if you sometimes get e-mails created by poorly-written mail programs or spam software).


This sample loads the message from .EML file and changes the date and time when the message was composed. In the modified message, it will appear that the message was composed earlier today at midnight, not at the current moment.

Then, the sample suppresses automatic setting the date and time to Now during sending, and sends the message.

using System;
using MailBee;
using MailBee.SmtpMail;
using MailBee.Mime;

class Sample
    static void Main(string[] args)
        // Load the message from file.
        MailMessage msg = new MailMessage();

        // Set the date to the current date and 00-00 time.
        msg.Date = DateTime.Today;

        // Suppress automatic setting Date to the current datetime
        // when the message gets sent.
        msg.Builder.SetDateOnSend = false;

        // Send it.
See Also