Hi,
I am working on a silverlight application. In this I need to send mail from a .aspx page. But while sending mail I am getting the below exception
"The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required."
Code I hve written is
string to = "test2@gmail.com"; System.Net.Mail.MailMessage MyMailMessage = new System.Net.Mail.MailMessage("test1@gmail.com", to,"Hi", "Test"); MyMailMessage.IsBodyHtml = true; System.Net.NetworkCredential mailAuthentication = new System.Net.NetworkCredential("test1@gmail.com", "pswpsw"); System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587); mailClient.EnableSsl = true; mailClient.UseDefaultCredentials = false; mailClient.Credentials = mailAuthentication; mailClient.Send(MyMailMessage);
If you have have any idea to solve this please reply me.
Thanks in advance.
|
| Author: Gaurav Arora 02 Nov 2009 | Member Level: Diamond | Rating:  Points: 2 |
Whenever you're sending email through an SSL SMTP like GMail, then you have to set the SmtpClient.EnableSsl to True.
I refer you check this complete code : http://www.dotnetspider.com/resources/21608-Sending-Email-Through-ASP-NET-using-C.aspx
Thanks & regards, Gaurav Arora - Sr. Editor Me in My Own Style
|
| Author: NekkantiDivya 02 Nov 2009 | Member Level: Gold | Rating:  Points: 2 |
Hi Gaurav Arora,
Thank your for your reply. Here I got this error because of wrong password. So I corrected it and now it is working fine
|
| Author: Kishor Dalwadi 02 Nov 2009 | Member Level: Silver | Rating:  Points: 2 |
I think this code is ok. But u check your details.
|