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@gmail.com", "xxx");
mail.To.Add("xxx@xxx.com");
mail.Subject = "subject";
mail.From = new System.Net.Mail.MailAddress("xxx@gmail.com");
mail.IsBodyHtml = true;
mail.Body = "message";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Credentials = cred;
smtp.Port = 587;
smtp.Send(mail);
}
}
_______________________________________________________________________
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.