Possible Duplicate:
Send email using System.Net.Mail through gmail. (C#)
I am using this code to send email using C# .Net but it generates error at run-time. The Code is:
MailMessage MyMailMessage = new MailMessage("example@gmail.com", "example@gmail.com",
"write your subject Here ", "Hi,This is the test message ");
MyMailMessage.IsBodyHtml = false;
NetworkCredential mailAuthentication = new NetworkCredential("example@gmail.com","xxxxxxxx");
SmtpClient mailClient = new SmtpClient("smtp.gmail.com", 587);
mailClient.EnableSsl = true;
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = mailAuthentication;
mailClient.Send(MyMailMessage);
After adding my gmail username and password and running the code an exception occurs at
mailClient.Send(MyMailMessage);
with message
Failure sending mail.
I've tried port 25 too but the problem is still there.
Is there anything else required other than Visual Studio and .Net Frameworks? I've all the versions of .Net Frameworks.
Please Help me!