youssefkhloufi
10/29/2016 - 9:36 PM

Send an email

Send an email

using System.Net.Mail;
using System.Windows.Forms;

void SendEMail(
    string from,   // e.g., "sender@abc.com"
    string to,     // e.g., "receiver@abc.com"
    string subject,// e.g., "Please read this!"
    string body)   // e.g., "Thanks for the memories."
{        
    try
    {
        // Construct a new e-mail message 
        SmtpClient client = new SmtpClient (smtpClient);
        client.Send (from, to, subject, body);
    } 
    catch (SmtpException ex)
    {
        MessageBox.Show ( ex.Message, "SendEMail: " + ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error );
    } 
}