Send E-Mail via SMTP
Description
This is a simple program that sends e-mail via SMTP
(Simple Mail Transfer Protocol) using the .Net 2.0 System.Net.Mail
namespace. As of .Net 2.0, the System.Web.Mail namespace is
obsolete.

Screen Shot
Specify the recipient's e-mail address, the subject, body, and smtp
server address and press Send to send the e-mail. If you don't know your
smtp server address you may be able to find it in your e-mail client's
configuration.
Code Snippet
Here's the code that sends the SMTP e-mail message:
using (MailMessage mailMessage = new MailMessage(new MailAddress(fromTextBox.Text),
new MailAddress(toTextBox.Text)))
{
mailMessage.Body = bodyTextBox.Text;
mailMessage.Subject = subjectTextBox.Text;
try
{
SmtpClient smtpClient = new SmtpClient(serverAddressTextBox.Text);
smtpClient.Send(mailMessage);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "EMail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
Requirements
This source code was developed with Microsoft Visual Studio 2005. Internet Connection Checker requires .Net 2.0.
Source Code