private void btnSend_Click(object sender, EventArgs e)
{
    string sTo = txtToEmailAddress.Text;
    string sFrom = txtEmail.Text;
    string sSubject = txtSubject.Text;
    string sBody = txtBody.Text;
try
{
    MailMessage mail = new MailMessage(sFrom, sTo, sSubject, sBody);
    SmtpClient client = new SmtpClient("IP address");
    client.Send(mail);
    MessageBox.Show("Mail Successfully Sent");
    txtSubject.Text = "";
    txtEmail.Text = "";
    txtBody.Text = "";
}
catch (Exception)
{
    MessageBox.Show("Mail Sending Fail");
}
}
No comments:
Post a Comment