Sets the date of the message creation as a string.
This method sets the value of Date header of the message. The value should be in RFC822 format (like Tue, 09 Oct 2007 12:36:00 -0300), but this method allows setting any value except a null reference. If you specify it as an empty string, Date header will not be added to the message at all.
To set this date as DateTime value, use Date property.
Note MailBee sets the date automatically to the current datetime when the message gets sent or submitted to the pickup folder. To suppress this, setmsg.Builder.SetDateOnSend = false(assumingmsgis MailMessage instance) prior to sending the message.
| Exception Type | Condition |
|---|---|
| MailBeeInvalidArgumentException | date is a null reference (Nothing in Visual Basic). |
This sample creates a new message and sets the the date when it was composed.
[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(); Console.WriteLine(msg.Date.ToString()); msg.SetDateFromString("Thu, 31 Mar 2005 17:34:25 -0400"); Console.WriteLine(msg.Date.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 Console.WriteLine(msg.Date.ToString()) msg.SetDateFromString("Thu, 31 Mar 2005 17:34:25 -0400") Console.WriteLine(msg.Date.ToString())
MailMessage Class | MailBee.Mime Namespace | Date