Forum Moderators: open

Message Too Old, No Replies

Need help with Comments Form in ASP.NET

networkcredentials, web.config and post issues

         

qasmuhammad

1:11 am on Oct 3, 2005 (gmt 0)



I am trying to make a comments page on my webpage. This is my first try and looking at the MSDN site this is what I made. It does not work right now and I have added inline comments on where my problems is. Please help.

<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Net.Mail" %>
<script language="C#" runat="server">
string MailFrom, MailTo = "";
void Button_Click(Object sender, EventArgs e)
{
MailFrom = ContactEmail.Text;
MailTo = "a@b.com";
MailMessage Email = new MailMessage(MailFrom, MailTo);
Email.Subject = "Website Comments";

// Not sure if I need this, am adding it cause I want line breaks in the e-mail message I get.
//
// Email.IsBodyHtml = true;

// Need help with the body, I want to be able to place the First Name and the Last name from
// my form in the e-mail message, as well as the comments user added.
//
// Email.Body

// Trying to add the credentials here, domain will not accept. should I add them in web.config?
// If yes, I am not sure how to do that, please help.
//
// SmtpClient client = new SmtpClient();
// client.Credentials = CredentialCache.DefaultNetworkCredentials;
// client.Send(Email);

}
</script>

<form method="post" runat="server">
<p>
Name:<br />
<asp:TextBox ID="ContactName" Columns="50" runat="server" />
</p>
<p>
E-Mail Address:<br />
<asp:TextBox ID="ContactEmail" Columns="50" runat="server" />
<asp:RegularExpressionValidator ControlToValidate="ContactEmail" Text="Invalid Email Address!" ValidationExpression="\S+@\S+\.\S{2,3}" runat="Server" />
</p>
<p>
Comments:<br />
<asp:TextBox ID="EmailBody" TextMode="MultiLine" Columns="75" Height="150px" Text="Please enter comments." runat="server" />
</p>
<p>
<asp:Button Text="Send" OnClick="Button_Click" runat="server" />
</p>
</form>

mattglet

10:21 pm on Oct 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What is the error message you are getting?

qasmuhammad

11:15 pm on Oct 3, 2005 (gmt 0)



This is what I get.

"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"

As far as I can track it, my e-mail credentials are not correct and my SMTP host is not letting me log in with the user name and password.

Is there a better way to pass this info to the smtp client?

tomasz

11:31 am on Oct 4, 2005 (gmt 0)

10+ Year Member



Did you set up remote smtp server on your box?

qasmuhammad

6:19 pm on Oct 4, 2005 (gmt 0)



I am using a hosting service with godaddy.com and was trying to use the smtp server they have or maybe my own ISP's credentials. Both seem to fail to authenticate.