Good Evening Sir, I have Developec Website in ASP.NET, I When end user is trying to connect me but Email, is not sending,
try { MailMessage mailMessage = new MailMessage(); mailMessage.From = new MailAddress("[email protected]"); mailMessage.To.Add("[email protected]"); mailMessage.Subject = "Inquiry for " + ddlEnquiryType.SelectedItem.Text; mailMessage.Body = "<b>Name:</b>" + txtName.Text + "<br/>" + "<b>Email:</b>" + txtEmail.Text + "<br/>" + "<b>Mobile:</b>" + txtMobile.Text + "<br/>" + "<b>Enquiry Type:</b>" + ddlEnquiryType.SelectedItem.Text + "<br/>" + "<b>Message:</b>" + txtMessage.Text; mailMessage.IsBodyHtml = true; SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587); smtpClient.EnableSsl = true; smtpClient.Credentials = new System.Net.NetworkCredential("[email protected]", "Password"); smtpClient.Send(mailMessage); ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('Thank you for contacting us, Power Educare Team Will Contact You Soon...')</script>"); lblStatus.ForeColor = System.Drawing.Color.Green; lblStatus.Text = "Thank you for contacting us"; txtName.Text = txtEmail.Text = txtMobile.Text = txtMessage.Text = string.Empty;
} catch (Exception ex) { //Log= Event Viewer or table lblStatus.ForeColor = System.Drawing.Color.Red; lblStatus.Text = "There is an unknown problem. Please try later"; }
Can you Help me out.
Thanks & Regards