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 to Queue on Schedule]

Imports EASendMail

Public Sub SendMailToQueue(sender As String,
    recipient As String,
    subject As String)

    Try
        Dim oMail As SmtpMail = New SmtpMail("TryIt")
        oMail.From = New MailAddress(sender)
        ' Separate multiple addresses by comma(,)
        oMail.To = New AddressCollection(recipient)

        ' 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", 
                        oMail.To.ToEncodedString(HeaderEncodingType.EncodingAuto, "utf-8"))

        oMail.Subject = subject
        oMail.TextBody = "Dear {$var_rcptname}, your email address is {$var_rcptaddr}"

        ' send this email after 10 minutes
        ' you can also cancel the scheduled task in EASendMail Service Manager->Queue Monitor->Scheduled Tasks 
        oMail.Date = System.DateTime.Now.AddMinutes(10)

        ' Your SMTP server address, if you don't set server, 
        ' EASendMail service uses the server setting in EASendMail Service Manager.
        Dim oServer As New SmtpServer("smtp.emailarchitect.net")

        ' User and password for ESMTP authentication
        oServer.User = "test@emailarchitect.net"
        oServer.Password = "testpassword"

        ' If server supports SSL/TLS connection, SSL/TLS is used automatically.
        oServer.ConnectType = SmtpConnectType.ConnectTryTLS

        Dim oSmtp As SmtpClient = New SmtpClient()
        oSmtp.SendMailToQueue(oServer, oMail)

        ' If you want to use SMTP server setting in EASendMail Service Manager, use
        ' oSmtp.SendMailToQueue(Nothing, oMail)
        Console.WriteLine("The message was sent to EASendMail Service successfully!")

    Catch exp As Exception
        Console.WriteLine("Exception: Common: {0}, please make sure you installed EASendMail Service on the server!", exp.Message)
    End Try

End Sub


[C# - Send Email to Queue on Schedule] using System; using System.Collections; using EASendMail; public void SendMailToQueue(string sender, string recipient, string subject) { try { SmtpMail oMail = new SmtpMail("TryIt"); oMail.From = sender; // Separate multiple addresses by comma(,) oMail.To = recipient; // To avoid too many email addresses appear in To header, // use following code only display the current recipient oMail.Headers.ReplaceHeader("To", "\"{$var_rcptname}\" <{$var_rcptaddr}>"); oMail.Headers.ReplaceHeader("X-Rcpt-To", oMail.To.ToEncodedString(HeaderEncodingType.EncodingAuto, "utf-8")); oMail.Subject = subject; oMail.TextBody = "Dear {$var_rcptname}, your email address is {$var_rcptaddr}"; // send the email after 10 minutes // you can also cancel the scheduled task in EASendMail Service Manager->Queue Monitor->Scheduled Tasks oMail.Date = DateTime.Now.AddMinutes(10); // Your SMTP server address, if you don't set server, // EASendMail service uses the server setting in EASendMail Service Manager. SmtpServer oServer = new SmtpServer("smtp.emailarchitect.net"); // User and password for ESMTP authentication oServer.User = "test@emailarchitect.net"; oServer.Password = "test"; // Most mordern SMTP servers require SSL/TLS connection now. // ConnectTryTLS means if server supports SSL/TLS, SSL/TLS will be used automatically. oServer.ConnectType = SmtpConnectType.ConnectTryTLS; SmtpClient oSmtp = new SmtpClient(); oSmtp.SendMailToQueue(oServer, oMail); // If you want to use SMTP server setting in EASendMail Service Manager, use // oSmtp.SendMailToQueue(null, oMail); Console.WriteLine("The message was sent to EASendMail Service successfully!"); } catch (Exception exp) { Console.WriteLine("Exception: {0}, please make sure you installed EASendMail Service on the server!", exp.Message); } }

See Also

Work with EASendMail Service (Email Queuing)