Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Feb 21, 2010 06:33 AM|LINK
Try after removing the following line of code:
mySmtpClient.Port = 587;
If it does n't work, try using the port 465.
Also, remove the settings in the web.config. Folllowing is the sample code that sends a simple email using Gmail smtp, it is in VB but you can surely have an idea:
Dim mm As New MailMessage()
mm.From = New MailAddress("FromAddress")
mm.Subject = "Test Subject"
mm.Body = "Message Details"
Dim ss As New SmtpClient("smtp.gmail.com")
ss.Credentials = New System.Net.NetworkCredential("username","password")
ss.EnableSsl = True
The above code will work, if you are not behind a proxy and directly connected to the internet.
asp .net 2. 0