MailMessageSetDateFromString Method |
Namespace: MailBee.Mime
Exception | Condition |
---|---|
MailBeeInvalidArgumentException | date is a null reference (Nothing in Visual Basic). |
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.
This method by default won't allow out-of-range values in date parts (for instance, 79 seconds while 59 is the maximum allowed value). You can, however, enable FixBadDates to let MailBee tolerate some not significant errors (although this is not recommended).
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, set msg.Builder.SetDateOnSend = false (assuming msg is MailMessage instance) prior to sending the message. |
// 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());