Click here to Skip to main content
15,907,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Error Geting The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. My code as
protected void Button1_Click(object sender, EventArgs e)
       MailMessage mail = new MailMessage();
       SmtpClient SmtpServer = new SmtpClient("");
       mail.From = new MailAddress("");
       mail.Subject = YourName.Text.ToString();
       mail.Body = Comments.Text.ToString();
       SmtpServer.Port = 587;
       SmtpServer.Credentials = new System.Net.NetworkCredential("RajnishMishra", "computer");
       SmtpServer.EnableSsl = true;
      // MessageBox.Show("mail Send");
Updated 21-Nov-14 19:07pm
Share this answer

a) go to gmail security center via this link blow or google search for “gmail secrity” and login with your gmail account

b) next to “security” / “Recent activity” , click to “view all events”

c) You will able to see “Unusual Activity” , it will show all unusual activity events, select related event and approval it via click ” Yes, That was me!”

// Click allow access to your Google account

Share this answer
using (MailMessage mm = new MailMessage("from email", "To email")

                   StreamReader reader = new StreamReader(System.Web.HttpContext.Current.Server.MapPath("~/HtmlPage.html"));
                   string readFile = reader.ReadToEnd();
                   string myString = "";
                   myString = readFile;
                   string fname=dttemp.Rows[0][1].ToString();
                   myString = myString.Replace("$$fname$$", fname);
                   mm.Subject = "Your Subject";
                   mm.Body = myString.ToString();
                   mm.IsBodyHtml = true;
                   SmtpClient smtp = new SmtpClient();
                   smtp.Host = "";
                   smtp.EnableSsl = true;
                   NetworkCredential NetworkCred = new NetworkCredential("from Email", "From Password");
                   smtp.UseDefaultCredentials = false;
                   smtp.Credentials = NetworkCred;
                   smtp.Port = 587;

Share this answer

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