Hi guys,

hope you can help. I have installed Visual Web Developed and started learning ASP.NET with c#.

I am currently trying to build a website that sends email through gmail's smtp, here's the code:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;
using System.Net;

public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

System.Net.NetworkCredential cred = new System.Net.NetworkCredential("", "xxx");

mail.Subject = "subject";

mail.From = new System.Net.Mail.MailAddress("");
mail.IsBodyHtml = true;
mail.Body = "message";

System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("");
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Credentials = cred;
smtp.Port = 587;


And I am getting this error message:

Server Error in '/email' Application.
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

I am testing the app on the server that's integrated in Visual Web Developer, could that be the problem What else could it be

Please help.

Re: .NET Framework Networking and Communication Smtp with c# through gmail.



the fact that you are testing in web dev should not have any impact.

the error you get looks like a timeout, so either your request never made it there, or it took too long.

do you have a firewall running if so, turn it off and try again.

Otherwise wrap your code in a try catch and see if there is any innerexception that gives you more detail..

Hope this helps, please close the thread if it does

Re: .NET Framework Networking and Communication Smtp with c# through gmail.


indeed, its a good point picked up about the firewall - some firewalls block sending data from applications, be it a web app running from your box or a winform app - check the firewall, as suggested previously - the same applies for anti virus software too. In addition, be sure that the configuration settings are correctly configured for the gmail account