protected void btn_sub_Click(object sender, EventArgs e) { try { MailMessage loginInfo = new MailMessage(); loginInfo.From = new MailAddress(txt_eid.Text); loginInfo.To.Add("test@gmail.com"); loginInfo.Subject = txt_sub.Text; loginInfo.IsBodyHtml = true; loginInfo.Body = "Name:-" + txt_name.Text + "<br><br>"; loginInfo.Body += "Email Id:-" + txt_eid.Text + "<br><br>"; loginInfo.Body += "Mobile No:-" + txtMobile.Text + "<br><br>"; //loginInfo.Body += "Subject:-" + txt_sub.Text + "<br><br>"; loginInfo.Body += "Message:-" + txt_msg.Text + ""; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.EnableSsl = true; smtp.Credentials = new System.Net.NetworkCredential("test@gmail.com", "****"); //here instead of test i have write my own EMail id and password smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Send(loginInfo); Msg.Visible = true; Msg.Text = "Thanks for Contact us We will Contect You Very Soon"; txt_name.Text = ""; txt_eid.Text = ""; txt_sub.Text = ""; txt_msg.Text = ""; } catch (Exception ex) { Msg.Visible = true; Msg.Text = "Your Message is Not Send"; //ex.ToString(); } }
loginInfo.From = new MailAddress(txt_eid.Text);
loginInfo.From = new MailAddress("test@gmail.com","customeremailid@something.com/or/txt_eid.Text");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)