MailBee.NET Objects 3.1

MailMessage.SetDateFromString Method 

Sets the date of the message creation as a string.

public void SetDateFromString(
   string date
);

Parameters

date
A string in RFC822 data format containing the date and time of the moment when the message was composed.

Remarks

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, set msg.Builder.SetDateOnSend = false (assuming msg is MailMessage instance) prior to sending the message.

Exceptions

Exception TypeCondition
MailBeeInvalidArgumentExceptiondate is a null reference (Nothing in Visual Basic).

Example

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())

See Also

MailMessage Class | MailBee.Mime Namespace | Date