C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » Silverlight »

How to send mail [Error: The SMTP server requires a secure connection or the client ]


Posted Date: 02 Nov 2009      Posted By: NekkantiDivya      Member Level: Gold     Points: 1   Responses: 3



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.






Responses

Author: Gaurav Arora    02 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     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 2009Member Level: GoldRating: 2 out of 52 out of 5     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 2009Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

I think this code is ok. But u check your details.


Post Reply
You must Sign In to post a response.
Next : Silverlight
Previous : How to access session variable in silver light
Return to Discussion Forum
Post New Message
Category: Silverlight

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use