Hello I am having a few issues with the last try it out section of chapter 9.
I am getting this error
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 92.242.140.2:995
I did have a couple errors prior to that but managed to fix them. Here is the code that I have which is exactly the same from the book
C# code
protected void SendButton_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
string fileName = Server.MapPath("~/App_Data/ContactForm.txt");
string mailBody = File.ReadAllText(fileName);
mailBody = mailBody.Replace("##Name##", Name.Text);
mailBody = mailBody.Replace("##Email##", EmailAddress.Text);
mailBody = mailBody.Replace("##HomePhone##", PhoneHome.Text);
mailBody = mailBody.Replace("##BusinessPhone##", PhoneBusiness.Text);
mailBody = mailBody.Replace("##Comments##", Comments.Text);
MailMessage myMessage = new MailMessage();
myMessage.Subject = "Response from web site";
myMessage.Body = mailBody;
myMessage.From = new MailAddress("
[email protected]", "Stephen Brown");
myMessage.To.Add(new MailAddress("
[email protected]", "Stephen Brown"));
SmtpClient mySmtpClient = new SmtpClient();
mySmtpClient.Send(myMessage);
Message.Visible = true;
FormTable.Visible = false;
}
}
web.config code
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<pages theme="Monochrome">
<controls>
<add tagPrefix="Wrox" tagName="Banner" src="~/Controls/Banner.ascx"/>
</controls>
</pages>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="Stephen Brown <
[email protected]>">
<network enableSsl="true" userName="
[email protected]" host="outgoing.gmail.com "/>
</smtp>
</mailSettings>
</system.net>
</configuration>
thanks for any help.
I also did try changing outgoing.gmail.com to stmp.gmail.com which actually gave me this error
Unable to read data from the transport connection: net_io_connectionclosed.