Click here to Skip to main content
15,122,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys i got this code below to send email using my gmail account and i get this error all the time "Fail sending email"

MailMessage mail = new MailMessage();
SmtpClient smtp = new SmtpClient();

smtp.Host = "";
smtp.Port = 587;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = true;
smtp.Credentials = new NetworkCredential("", "thisMyPassword");

MailAddress emailSender = new MailAddress("", "BOOM");
mail.From = emailSender;
MailAddress receipient = new MailAddress(txtTo.Text);
mail.Body = txtBody.InnerText.ToString();
mail.Subject = txtSubject.Text;

I tried lots of ather codes in the web, Do i need settings in my web.config file?

1 solution


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