Click here to Skip to main content
15,891,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am getting the following error message:

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

I am using the following code:
public void sendmail()
    {
        MailMessage message = new MailMessage(new MailAddress(smtp_user_id), new MailAddress(txtemail.Text.ToString().Trim()));      
        message.Subject = "User Id and Password";
        message.Body = " :: Welcome \n\r " +
                       " \n\r " +
                       " NAME -" + " " + txtuser.Text.ToString() + " \n\r " +
                       " NO -" + " " + id.Text.ToString() + " \n\r " +
                       " USER ID -" + " " + txtmob.Text.ToString() + "\n\r" +
                       " PASSWORD -" + " " + pwd + "\n\r";
                        

        SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
        client.EnableSsl = true;
        client.UseDefaultCredentials = false;
        System.Net.NetworkCredential theCredential = new System.Net.NetworkCredential(smtp_user_id, smtp_user_pwd);
        client.Credentials = theCredential;
        client.Send(message);
    }
Posted
Comments
[no name] 24-Apr-12 6:51am    
Your error message is pretty clear. You need a valid user name and password. What is your question?

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900