Click here to Skip to main content
16,020,343 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
protected void btnSubmit_Click(object sender, EventArgs e)
{
    try
    {
        MailMessage Msg = new MailMessage();
        // Sender e-mail address.
        Msg.From = new MailAddress(txtEmail.Text);
        // Recipient e-mail address.
        Msg.To.Add("info@dhuvara.com");
        Msg.Subject = txtEmail.Text;
        Msg.Body = "NAME : " + txtName.Text + "EMAIL : " + txtEmail.Text + " SUBJECT : " + txtSubject.Text + "MESSAGE: " + txtMessage.Text;
        Msg.IsBodyHtml = true;
        // your remote SMTP server IP.
        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.live.com"; 
        smtp.Port = 587;
        Msg.Priority = MailPriority.Normal;
        smtp.UseDefaultCredentials = false;
        smtp.Credentials = new System.Net.NetworkCredential("info@dhuvara.com", "SolaiMail");
        smtp.EnableSsl = true;
        smtp.Send(Msg);
        //Msg = null;
        lbltxt.Text = "Thanks for Contact us";
        // Clear the textbox valuess
        txtName.Text = "";
        txtSubject.Text = "";
        txtMessage.Text = "";
        txtEmail.Text = "";
    }
    catch (Exception ex)
    {
        Console.WriteLine("{0} Exception caught.", ex.ToString());
    }
Posted
Updated 6-Jan-14 21:35pm
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900