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.gmail.com";
smtp.Port = 587;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = true;
smtp.Credentials = new NetworkCredential("Ngqandu.Anele@gmail.com", "thisMyPassword");

MailAddress emailSender = new MailAddress("Ngqandu.Anele@gmail.com", "BOOM");
mail.From = emailSender;
MailAddress receipient = new MailAddress(txtTo.Text);
mail.To.Add(receipient);
mail.Body = txtBody.InnerText.ToString();
mail.Subject = txtSubject.Text;
smtp.Send(mail);


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

1 solution

   
v2

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