Sending email using asp.net

May 10 2015 8:03 PM
I wrote a sending email in asp.net and I get this error. I don't Know how to solve it
 
The error :

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.

The code :
MailMessage msg = new MailMessage();
msg.From = new MailAddress(TextBox1.Text, "RUW Sport Center");
msg.To.Add(new MailAddress (TextBox3.Text));
msg.Subject = (TextBox4.Text);
msg.Body = TextBox5.Text;
msg.IsBodyHtml = true;
SmtpClient sc = new SmtpClient();
sc.Host = "smtp.gmail.com";
sc.Port = 25;
sc.Credentials = new NetworkCredential(TextBox1.Text, TextBox2.Text);
sc.EnableSsl = true;
sc.Send(msg);
Msgbx("Mail Send");
 

Answers (5)