Hi all,
i am developing web application, so if users want to use this application,first they should be register their details,at the time i have to send Userid and password to their Email address.now i'm have a code but it is not working,i got one error from this code.
the error is " SMTP Exception was caught: The SMTP Server requiers a secure connection or the client was not authenticated. the server response was :5.5.1 Authentication required ".
And also i attached my code.
Please help me anyone.,

Thank you

public Boolean SendMail(String mailId, String mailBody)

            System.Net.Mail.MailMessage message;
            message = new System.Net.Mail.MailMessage("\"Twaik Group\" <mmmm@gmail.com>", mailId, "Company name", mailBody);
            message.Priority = MailPriority.High;
            message.IsBodyHtml = true;

            //SmtpClient client = new SmtpClient("");
            SmtpClient client = new SmtpClient();
            client.Host = "smtp.gmail.com";
            client.Port = 25;
            client.EnableSsl = true;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;
            client.Credentials = new System.Net.NetworkCredential("mmmm@gmail.com", "***********");

            return true;
            return false;


Found this code in another post and it works for me:

MailMessage Message = new MailMessage();
Message.From = new MailAddress("NewUser@somewhere.com", "New User", Encoding.UTF8);
Message.Subject = "Test";
Message.SubjectEncoding = Encoding.UTF8;
Message.Body = "Test";
Message.BodyEncoding = Encoding.UTF8;
Message.IsBodyHtml = false;
Message.Priority = MailPriority.High;
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.Credentials = new NetworkCredential("******@gmail.com", "******");
client.Port = 587;
client.Host = "smtp.gmail.com";
client.EnableSsl = true;

thank you Mr.tinstaafl., now its working...

You're very welcome. Please remember to mark this solved thanks.

Here is an example

MailMessage mailMessage = new MailMessage(new MailAddress("sender@email.com", "Sender Name"), new MailAddress("email@email.com"));
mailMessage.Subject = "Some subject";
mailMessage.Body = msg;
mailMessage.IsBodyHtml = true;
SmtpClient smtpClient = new SmtpClient();

Setup configuration in web.config

         password="xxxx" />

Thank you Mr.Annaharris... thanks for helping me..