SmtpMail.Date Property


Gets or sets the date time of the e-mail message.

[Visual Basic]
Public Property Date As DateTime
[C#]
public DateTime Date {get; set;}
[C++]
public: __property DateTime^ get_Date();
public: __property void set_Date(DateTime^);
[JScript]
public function get Date() : DateTime;
public function set Date(DateTime);

Property Value

A System.DateTime value indicating the date time of the e-mail message.

Remarks

The default value is the DateTime that the SmtpMail is created.
If you send email by EASendMail Service by SendMailToQueue or SendMailToQueue, you can specify a DateTime to send the email in schedule.

Example

[Visual Basic, C#] The following example demonstrates how to send email with EASendMail SMTP Component. To get the full samples of EASendMail, please refer to Samples section.

[VB - Send Email in Schedule]
Imports EASendMail

Public Sub SendMail( sFrom As String, _ 
    sTo As String, _ 
    sSubject As String )

    Dim oMail As SmtpMail = New SmtpMail("TryIt")
    Dim oSmtp As SmtpClient = New SmtpClient
 
    Dim errStr As String = ""

    Try
        oMail.From = New MailAddress( sFrom )
        'Please separate multiple addresses by comma(,)
        oMail.To = New AddressCollection(sTo) 
        
        'To avoid too many email addresses appear in To header, using the
           ' following code only display the current recipient
        oMail.Headers.ReplaceHeader( "To", """{$var_rcptname}"" <{$var_rcptaddr}>" )
        oMail.Headers.ReplaceHeader( "X-Rcpt-To", new AddressCollection( txtTo.Text ).ToEncodedString( HeaderEncodingType.EncodingAuto, charset ))
      
        oMail.Subject = sSubject
        oMail.TextBody = "Dear {$var_rcptname}, your email address is {$var_rcptaddr}"
        
        ' EASendMail service will send the email after 10 minutes,
        oMail.Date = System.DateTime.Now.AddMinutes( 10 )

        oSmtp.SendMailToQueue( null, oMail)
        MessageBox.Show( "The message was sent to EASendMail Service successfully!" )

    Catch exp As System.Exception
        errStr = String.Format("Exception: Common: {0}", exp.Message)
        errStr += "Please make sure you installed EASendMail Service on the server!"                
    End Try

    If errStr.Length > 0 Then
        MessageBox.Show(errStr)
    End If
End Sub

[C# - Send Email in Schedule]
using System;
using System.Collections;
using EASendMail;

public void SendMail( string sFrom, 
    string sTo, 
    string sSubject )
{
    SmtpMail oMail = new SmtpMail("TryIt");
    SmtpClient oSmtp = new SmtpClient();
    string err = "";

    try
    {
        oMail.From = sFrom;
        //Please separate multiple addresses by comma(,)
        oMail.To = sTo;
        
        //To avoid too many email addresses appear in To header, using the
        // following code only 
        //display the current recipient
        oMail.Headers.ReplaceHeader( "To", "\"{$var_rcptname}\" <{$var_rcptaddr}>" );
        oMail.Headers.ReplaceHeader( "X-Rcpt-To", new AddressCollection( txtTo.Text ).ToEncodedString( HeaderEncodingType.EncodingAuto, charset ));
    
        oMail.Subject = sSubject;
        oMail.TextBody = "Dear {$var_rcptname}, your email address is {$var_rcptaddr}";
       
        // EASendMail service will send the email after 10 minutes,
        oMail.Date = System.DateTime.Now.AddMinutes( 10 );
    
        oSmtp.SendMailToQueue( null, oMail  );
        MessageBox.Show( "The message was sent to EASendMail Service successfully!" );

    }
    catch( System.Exception exp )
    {
        err = String.Format( "Exception: Common: {0}", exp.Message );
        err += "Please make sure you installed EASendMail Service on the server!";          
    }   
    
    if( err.Length > 0  )
    {
        MessageBox.Show( err );
    }
}

See Also

Work with EASendMail Service (Email Queuing)