1. No Profile Picture
    Contributing User
    ASP Discoverer (100 - 499 posts)

    Join Date
    Dec 2005
    Rep Power

    Sending contact form - problem


    For about three weeks I have been trying to resolve a Web page contact form. It just doesn't send. I don't get any server error message and my Web hosting service tells me that I have the correct SMTP server credentials.

    I have three fields and a Send button (stripped):

    <asp:TextBox ID="your_name" runat="server" required></asp:TextBox></p>
    <asp:TextBox ID="your_email" runat="server" required></asp:TextBox></p><br />
    <textarea id="your_message" cols="50" rows="5" runat="server" required></textarea></p><br />
    My SMTP looks like this:

    Protected Sub contact_submitted_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles contact_submitted.Click
            Dim myMessage As New MailMessage
            Dim Smtpserver As New SmtpClient
            Dim Name As String = "yourname"
            Dim Email As String = "youremail"
            Dim Message As String = "yourmessage"
            'Request.Form - extract data from form fields
            Dim yourname As String = Request.Form("your_name")
            Dim youremail As String = Request.Form("your_email")
            Dim yourmessage As String = Request.Form("your_message")
            'create the mail message
            myMessage.From = New MailAddress("info@myplace.net") 'Webmaster's email
            myMessage.To.Add(New MailAddress("myemail@myplace.net")) 'recipient
            myMessage.ReplyToList.Add(youremail) 'sender's email
            myMessage.Body = yourmessage
            myMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
            myMessage.IsBodyHtml = True
            myMessage.Priority = MailPriority.High
            Smtpserver.DeliveryMethod = SmtpDeliveryMethod.Network
            Smtpserver.Host = ("mail.server")
            Smtpserver.Port = 25
            Smtpserver.EnableSsl = False
            Dim basicAuthenticationInfo As New System.Net.NetworkCredential("info@myplace.net", "******")
            'Smtpserver.Credentials = basicAuthenticationInfo
            Smtpserver.UseDefaultCredentials = True
            myMessage = Nothing
            Smtpserver = Nothing
           Response.Redirect("~/thankyou.aspx?your_name={0}", yourname)
        End Sub
    When I debug the code the page loads correctly in my browser, but I get the following in my Output/Debug window at the bottom of Visual Studio (Express for Web 2013):

    0x800a139e - JavaScript runtime error: SyntaxError
    Exception was thrown at line 2, column 7006 in https://code.jquery.com/jquery-2.1.1.min.js
    0x800a139e - JavaScript runtime error: SyntaxError
    The program '[1004] iexplore.exe' has exited with code 0 (0x0).
    The program '[4344] iisexpress.exe' has exited with code 0 (0x0).
    Is it likely that that JS file is causing the page not to send and how may I resolve it, please?

    Many thanks.

  2. #2
  3. I do .NET for a living
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Sep 2003
    Rep Power
    Well, firstly, the error says it's a javascript syntax error, so you should have included your aspx page code where the javascript lives (or the javascript include file if reading from a .js file).
    Second, the line: Smtpserver.Host = ("mail.server") looks suspect to me. The host address is either an IP address or a domain name that resolves to an IP address and is usually written like this:
    Smtpserver.Host = yoursmpt.servername (NOTE: no parens used).
    Last edited by rclark; August 27th, 2015 at 02:53 PM.
    Roger (.NET MCP)
  4. #3
  5. No Profile Picture
    Contributing User
    ASP Discoverer (100 - 499 posts)

    Join Date
    Dec 2005
    Rep Power
    Hello Roger

    Thanks for your reply.

    I have since been told that the JS error would not prevent the email from being sent (it is used for fading images on the page). 'Mail.Server' was the smtp host given to me by my Web hosting service and I actually use that same host on another site that works.

    It seems that my SMTP code is not even being processed because after the user clicks 'Send' the URL does not change in the address bar, so it never gets to the 'thank you' page. I think it called a server 301 error, but I don't know how to force the browser to move to thankyou.aspx once 'Send' has been clicked.

    This is a new domain with the same WEb hosting service and does not use virtual directories.

    Do I need to alter anything in Web.config or global.aspa in order to force that it to move to thankyou.aspx?

    Many thanks.


Similar Threads

  1. ASP contact form to email is not sending to my email
    By Ellablue in forum ASP Development
    Replies: 2
    Last Post: January 21st, 2008, 05:45 AM
  2. Contact Form Help?
    By dannbkk in forum ASP Development
    Replies: 12
    Last Post: October 27th, 2006, 05:46 AM
  3. Contact form sending through email using cdosys
    By kumar_373 in forum ASP Development
    Replies: 10
    Last Post: October 9th, 2006, 05:12 AM
  4. Can you help me to fix this problem with sending form
    By computerMan in forum ASP Development
    Replies: 22
    Last Post: February 7th, 2006, 07:52 AM
  5. Problem with form of aspemail contact
    By paulinho_ivoce in forum ASP Development
    Replies: 1
    Last Post: August 17th, 2005, 06:44 PM

IMN logo majestic logo threadwatch logo seochat tools logo