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 |
- 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;
- In your code where you would like to send an email message, create an
instance of the Smtp.NET object:
SmtpServer mySmtpServer = new SmtpServer();
- Set the properties for the "from" and "to" email addresses:
mySmtpServer.FromAddress = "from@domain.com";
mySmtpServer.ToAddress = "to@domain.com";
- Send the mail message:
mySmtpServer.Send();
- Complile the project or view the web page to ensure you don't have any errors.
|
VB.NET Example |
- 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
- 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()
- Set the properties for the "from" and "to" email addresses:
mySmtpServer.FromAddress = "from@domain.com"
mySmtpServer.ToAddress = "to@domain.com"
- Send the mail message:
mySmtpServer.Send()
- Complile the project or view the web page to ensure you don't have any errors.
|
|