Smtp.NET Getting Started

Using Smtp.NET in your application is quick and painless. Once it is installed, follow these 5 quick steps:

This example will send a simple message through the web server on the machine it is running on, i.e. "localhost". For Windows NT/2000/XP, "localhost" is frequently the MS Smtp Server.

C# Example


  1. Open your page with code (either the .cs file in VS.NET or the Code view in Web Matrix) and add a using statement: 
    using SmtpDotNet; 
  2. In your code where you would like to send an email message, create an instance of the Smtp.NET object:
    SmtpServer mySmtpServer = new SmtpServer(); 
  3. Set the properties for the "from" and "to" email addresses:
    mySmtpServer.FromAddress = "from@domain.com";
    mySmtpServer.ToAddress = "to@domain.com";
  4. Send the mail message:
    mySmtpServer.Send();
  5. Complile the project or view the web page to ensure you don't have any errors.

VB.NET Example


  1. Open your page with code (either the .vb file in VS.NET or the Code view in Web Matrix) and add a Imports statement: 
    Imports SmtpDotNet 
  2. In your code where you would like to send an email message, create an instance of the Smtp.NET object:
    SmtpServer mySmtpServer As new SmtpServer() 
  3. Set the properties for the "from" and "to" email addresses:
    mySmtpServer.FromAddress = "from@domain.com"
    mySmtpServer.ToAddress = "to@domain.com"
  4. Send the mail message:
    mySmtpServer.Send()
  5. Complile the project or view the web page to ensure you don't have any errors.