emailQ.NET Scheduled Send to Queue

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.

Why use this option? 

[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");
            }
            
            

[View VB Example]
 		
            Public Function SendEmail() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As Integer
            
                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"
                 
                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"
            
                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"
            
		 ' Send the message to emailQ.NET's Queue Directory
                 oSmtpDotNet.SendToPickupDirectory = 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\"
		
		         
                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     Exit Function
                 End If
            
                 ' Success!
                 Console.WriteLine("Message Queued")
            End Function