The example demonstrates sending a simple message to the queue for delivery.
[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;
// 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");
}