The example demonstrates sending a simple message to the IIS Pickup directory for scheduled
delivery through the IIS Virtual SMTP Server. 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 drop the file into the IIS Pickup directory.
NOTE: IIS Virtual SMTP Server does not support authentication with the use of .eml files
dropped in the pickup directory.
[View C# Example]
public void SendEmail()
{
SmtpServer oSmtpDotNet = new SmtpServer();
// 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 the IIS Pickup Directory
oSmtpDotNet.SendToPickupDirectory = true;
// Wait until the specified DateTime
oSmtpDotNet.QueueDateTime = DateTime.Now.AddMinutes(5);
// Specifying the Pickup Directory OVERRIDES the registry setting
// that is used in the emailQ.NET application.
oSmtpDotNet.PickupDirectory = "C:\\Inetpub\\mailroot\\Pickup";
int nRC = oSmtpDotNet.Send();
if ( nRC != (int)ReturnCodes.SUCCESS )
{
Console.WriteLine("Error #"+nRC+" occurred.");
Console.WriteLine(oSmtpDotNet.LastError);
return;
}
// Success!
Console.WriteLine("Message Queued");
}