The example demonstrates sending a simple message to the emailQ.NET queue for scheduled
delivery through the specified ServerAddress. Internally, Smtp.NET creates a file with
an ".eml" extension, containing information that IIS uses to deliver messages. emailQ.NET
waits until the specified time to deliver to the specified ServerAddress.
[View C# Example]
public void SendEmail()
{
SmtpServer oSmtpDotNet = new SmtpServer();
// Set the remote server name. If left blank, "localhost" is used.
oSmtpDotNet.ServerAddress = "mail.domain.com"
// Message Addressing
oSmtpDotNet.ToAddress = "to@domain.com";
oSmtpDotNet.FromAddress = "from@domain.com";
// Set the message subject and body
oSmtpDotNet.Body = "This is the message";
oSmtpDotNet.Subject = "Routine email";
// Send the message to emailQ.NET's Queue Directory
oSmtpDotNet.SendToQueue = true;
// Wait until the specified DateTime
oSmtpDotNet.QueueDateTime = DateTime.Now.AddMinutes(5);
// Specifying the QueueDirectory OVERRIDES the registry setting
// that is used in the emailQ.NET application.
oSmtpDotNet.QueueDirectory = "C:\\Inetpub\\mailroot\\";
int nRC = oSmtpDotNet.Send();
if ( nRC != (int)ReturnCodes.SUCCESS )
{
Console.WriteLine("Error #"+nRC+" occurred.");
Console.WriteLine(oSmtpDotNet.LastError);
return;
}
// Success!
Console.WriteLine("Message Queued");
}