Here's the code to send an e-mail using .Net 2.0's System.Net.Mail namespace. Your SMTP server address is specified in the SmtpClient object's constructor. If you don't know your server address you may be able to find it in your e-mail client's configuration.
Note: the .Net 1.1 System.Web.Mail namespace is obsolete as of .Net 2.0. Use the System.Net.Mail namespace in .NET >= 2.0 apps.
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); } }
Title | Date |
.NET Public-Key (Asymmetric) Cryptography Demo | July 20, 2025 |
Raspberry Pi 3B+ Photo Frame | June 17, 2025 |
EBTCalc (Android) Version 1.53 is now available | May 19, 2024 |
Vault 3 Security Enhancements | October 24, 2023 |
Vault 3 is now available for Apple OSX M2 Mac Computers! | September 18, 2023 |
Vault (for Desktop) Version 0.77 Released | March 26, 2023 |
EBTCalc (Android) Version 1.44 is now available | October 12, 2021 |