New to asp.net. Need help debugging this email form.

Posted by Roeland on Stack Overflow See other posts from Stack Overflow or by Roeland
Published on 2010-03-29T17:29:00Z Indexed on 2010/03/29 17:33 UTC
Read the original article Hit count: 270

Filed under:
|
|

Hey guys,

First of all, I am a php developer and most of .net is alien to me which is why I am posting here!

I just migrated over a site from one set of webhosting to another. The whole site is written in .net. None of the site is database driven so most of it works, except for the contact form. The output on the site simple states there was an error with "There has been an error - please try to submit the contact form again, if you continue to experience problems, please notify our webmaster." This is just a simple message it pops out of it gets to the "catch" part of the email function.

I went into web.config and changed the parameters:

    <emailaddresses>
        <add name="System" value="[email protected]"/>
        <add name="Contact" value="[email protected]"/>
        <add name="Info" value="[email protected]"/>
    </emailaddresses>
    <general>
        <add name="WebSiteDomain" value="hoyespharmacy.com"/>
    </general>

Then the .cs file for contact contains the mail function EmailFormData():

private void EmailFormData()
{
    try
    {
        StringBuilder body = new StringBuilder();
        body.Append("Name" + ": " + txtName.Text + "\n\r");
        body.Append("Phone" + ": " + txtPhone.Text + "\n\r");
        body.Append("Email" + ": " + txtEmail.Text + "\n\r");
        body.Append("Fax" + ": " + txtEmail.Text + "\n\r");
        body.Append("Subject" + ": " + ddlSubject.SelectedValue + "\n\r");
        body.Append("Message" + ": " + txtMessage.Text);

        MailMessage mail = new MailMessage();
        mail.IsBodyHtml = false;
        mail.To.Add(new MailAddress(Settings.GetEmailAddress("System")));
        mail.Subject = "Contact Us Form Submission";
        mail.From = new MailAddress(Settings.GetEmailAddress("System"), Settings.WebSiteDomain);
        mail.Body = body.ToString();

        SmtpClient smtpcl = new SmtpClient();

        smtpcl.Send(mail);
    }
    catch
    {
        Utilities.RedirectPermanently(Request.Url.AbsolutePath + "?messageSent=false");
    }
}

How do I see what the actual error is. I figure I can do something with the "catch" part of the function.. Any pointers?

Thanks!

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about web-development