We are excited to announce that the IIS.NET Forums are moving to the new Microsoft Q&A experience. Learn more >

Problem when I press the submit button on my contact form [Answered]RSS

8 replies

Last post Sep 19, 2008 03:19 AM by aic

  • Problem when I press the submit button on my contact form

    Sep 13, 2008 05:23 AM|aic|LINK

     I am having a lot of trouble with my contact page and I am about to go crazy! Every time i press the submit button the 500 internal server error comes up. I have tried doing everything but have no idea what I am doing. I am still very new at all this and on top of everything I am probably posting this in the wrong place as well, so I apologize sincerely if I am in the wrong place.

     This is my contact2.htm page:

     <form action="sendmail2.asp" method="post" enctype="application/x-www-form-urlencoded" target="_self">
            <p align="right">Name:
              <input type="text" name="Name" />
              <br />
              <br />
              Email:
              <input type="text" name="Email" />
              <br />
              Country:
              <input type="text" name="Country" />
              <br />
              Tel:
              <input type="text" name="Tel" />
              <br />
              Company:
              <input type="text" name="Company" />
              <br />
              Website:
              <input type="text" name="Website" />
              <br />
              <br />
              Message:
              <textarea name="Message"></textarea>
            </p>
            <p align="right">
              <input type="submit" name="submit" value="Submit" />
            </p>
        </form>

     

    and here is my sendmail2.asp:

           <%
     ' declare variables
    Dim EmailFrom
    Dim EmailTo
    Dim Subject
    Dim Name
    Dim Email
    Dim Country
    Dim Tel
    Dim Company
    Dim Website
    Dim Message
    Dim Body

    ' get posted data into variables
    EmailFrom = "info@aicconsulting.co.uk"
    EmailTo = "info@aicconsulting.co.uk"
    Subject = "AIC Consulting Contact form"
    Name = Trim(Request.Form("Name"))
    Email = Trim(Request.Form("Email"))  
    Country = Trim(Request.Form("Country"))
    Tel = Trim(Request.Form("Tel"))
    Company = Trim(Request.Form("Company"))
    Website = Trim(Request.Form("Website"))
    Message = Trim(Request.Form("Message"))

    ' validation
    Dim validationOK
    validationOK=true
    If (validationOK=false) Then Response.Redirect("contact2error.htm?" & EmailFrom)

    ' prepare email body text
    Dim Body
    Body = Body & "Name: " & Name & VbCrLf
    Body = Body & "Email: " & Email & VbCrLf
    Body = Body & "Country: " & Country & VbCrLf
    Body = Body & "Tel: " & Tel & VbCrLf
    Body = Body & "Company: " & Company & VbCrLf
    Body = Body & "Website: " & Website & VbCrLf
    Body = Body & "Message: " & Message & VbCrLf

    ' send email
    Dim mail
    Set mail = Server.CreateObject("CDO.Message")
    mail.To = EmailTo
    mail.From = EmailFrom
    mail.Subject = Subject
    mail.Body = Body
    mail.Send

    ' redirect to success page
    Response.Redirect("contact2.htm?" & EmailFrom)
    %>

    I tried changing it to CDOSYS so maybe I missed something out when changing it. If someone knows what is going on, please may you help me!

     

    Any help will be greatly appreciated.

     thanks in advance.

     

    Contact Form CDO 500 internal server error

  • Re: Problem when I press the submit button on my contact form

    Sep 13, 2008 02:55 PM|steve schofield|LINK

    few things

    1) dim Body listed twice (remove one)

    2) Wrong method for body (HTMLBody or TextBody) are the method names
    http://www.w3schools.com/asp/asp_send_email.asp

    3) Make sure the SMTP service is installed and started

    4) Make sure the anonymous and / or application pool user has write permissions on the pickup folder
    http://weblogs.asp.net/steveschofield/archive/2008/09/12/cdosys-and-windows-server-2008-80070005-description-access-is-denied.aspx

     

    Steve Schofield
    Windows Server MVP - IIS
    http://iislogs.com/steveschofield
    http://www.IISLogs.com
    Log archival solution
    Install, Configure, Forget

  • Re: Problem when I press the submit button on my contact form

    Sep 13, 2008 05:10 PM|aic|LINK

    steve schofield

    few things

    1) dim Body listed twice (remove one)

    2) Wrong method for body (HTMLBody or TextBody) are the method names
    http://www.w3schools.com/asp/asp_send_email.asp

    3) Make sure the SMTP service is installed and started

    4) Make sure the anonymous and / or application pool user has write permissions on the pickup folder
    http://weblogs.asp.net/steveschofield/archive/2008/09/12/cdosys-and-windows-server-2008-80070005-description-access-is-denied.aspx

     

     

    thanks for the help. I think i managed to do the first two things that you asked for, but the second two..... I think i probably have to ask our server to do those for me, is that right? I had a look at your blog that you gave the link for and I am really sorry but I am so new at this that what you wrote there doesnt make any sense to me.

    my new sendmail2.asp now looks like this (is it correct?):

    <%
     ' declare variables
    Dim EmailFrom
    Dim EmailTo
    Dim Subject
    Dim Fullname
    Dim Email
    Dim Country
    Dim Tel
    Dim Company
    Dim Website
    Dim Message

    ' get posted data into variables
    EmailFrom = "info@aicconsulting.co.uk"
    EmailTo = "info@aicconsulting.co.uk"
    Subject = "AIC Consulting Contact form"
    Fullname = Trim(Request.Form("Fullname"))
    Email = Trim(Request.Form("Email")) 
    Country = Trim(Request.Form("Country"))
    Tel = Trim(Request.Form("Tel"))
    Company = Trim(Request.Form("Company"))
    Website = Trim(Request.Form("Website"))
    Message = Trim(Request.Form("Message"))

    ' validation
    Dim validationOK
    validationOK=true
    If (validationOK=false) Then Response.Redirect("contact2error.htm" & EmailFrom)

    ' prepare email body text
    Dim HTMLBody
    HTMLBody = HTMLBody & "Full Name: " & Fullname & VbCrLf
    HTMLBody = HTMLBody & "Email: " & Email & VbCrLf
    HTMLBody = HTMLBody & "Country: " & Country & VbCrLf
    HTMLBody = HTMLBody & "Tel: " & Tel & VbCrLf
    HTMLBody = HTMLBody & "Company: " & Company & VbCrLf
    HTMLBody = HTMLBody & "Website: " & Website & VbCrLf
    HTMLBody = HTMLBody & "Message: " & Message & VbCrLf

    ' send email
    Dim mail
    Set mail = Server.CreateObject("CDO.Message")
    mail.To = EmailTo
    mail.From = EmailFrom
    mail.Subject = Subject
    mail.HTMLBody = HTMLBody
    mail.Send

    ' redirect to success page
    Response.Redirect("contact2.htm" & EmailFrom)
    %>

     

    Thanks so much for all your help, it is greatly appreciated.

  • Re: Problem when I press the submit button on my contact form

    Sep 14, 2008 03:18 PM|steve schofield|LINK

    No worries.  Yes to #3, #4 those are server based things.  If this is an existing server, I suspect they are already setup.  I wanted to mention as an FYI.   Have you tried your code again since fixing #1, #2? I was able to get it work.

    Steve Schofield
    Windows Server MVP - IIS
    http://iislogs.com/steveschofield
    http://www.IISLogs.com
    Log archival solution
    Install, Configure, Forget

  • Re: Problem when I press the submit button on my contact form

    Sep 18, 2008 08:36 AM|aic|LINK

      Steve

     

    I was wondering that if you had time, would you be able to help me again? The contact form is still not working. I have asked the server to update the information you gave me before and they said that they have done that, that’s why I am a bit confused now. I have looked at the logs and the following message comes up now:

    The__SendUsing__configuration_value_is_invalid.__

    I searched it on the internet and one of the websites mentioned adding the following to the code:

     

    myMail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
    myMail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="127.0.0.1"
    myMail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=8025
    myMail.Configuration.Fields.Updat

     

    I changed the myMail to mail because the rest of my code says mail. Would this change anything??

     

    This is what my code looks like now:

     

    <%

     ' declare variables

    Dim EmailFrom

    Dim EmailTo

    Dim Subject

    Dim Fullname

    Dim Email

    Dim Country

    Dim Tel

    Dim Company

    Dim Website

    Dim Message

     

    ' get posted data into variables

    EmailFrom = "info@aicconsulting.co.uk"

    EmailTo = "info@aicconsulting.co.uk"

    Subject = "AIC Consulting Contact form"

    Fullname = Trim(Request.Form("Fullname"))

    Email = Trim(Request.Form("Email")) 

    Country = Trim(Request.Form("Country"))

    Tel = Trim(Request.Form("Tel"))

    Company = Trim(Request.Form("Company"))

    Website = Trim(Request.Form("Website"))

    Message = Trim(Request.Form("Message"))

     

    ' validation

    Dim validationOK

    validationOK=true

    If (validationOK=false) Then Response.Redirect("contact2error.htm" & EmailFrom)

     

    ' prepare email body text

    Dim HTMLBody

    HTMLBody = HTMLBody & "Full Name: " & Fullname & VbCrLf

    HTMLBody = HTMLBody & "Email: " & Email & VbCrLf

    HTMLBody = HTMLBody & "Country: " & Country & VbCrLf

    HTMLBody = HTMLBody & "Tel: " & Tel & VbCrLf

    HTMLBody = HTMLBody & "Company: " & Company & VbCrLf

    HTMLBody = HTMLBody & "Website: " & Website & VbCrLf

    HTMLBody = HTMLBody & "Message: " & Message & VbCrLf

     

    ' send email

    Dim mail

    Set mail = Server.CreateObject("CDO.Message")

    mail.To = EmailTo

    mail.From = EmailFrom

    mail.Subject = Subject

    mail.HTMLBody = HTMLBody

    mail.Send

     

    ' redirect to success page

    Response.Redirect("contact2.htm" & EmailFrom)

     

    mail.Configuration.Fields.Item _

    ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2

    mail.Configuration.Fields.Item _

    ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="127.0.0.1"

    mail.Configuration.Fields.Item _

    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=8025

    mail.Configuration.Fields.Updat

    %>

     

    I have asked the server again to make sure that they have done what you said I should do, might have been a bit lost in translation though so we will see tomorrow.

     

    Thanks for all you help so far.

  • Re: Problem when I press the submit button on my contact form

    Sep 18, 2008 08:56 AM|tomkmvp|LINK

    Your mail.Configuration section needs to go before the mail.send and should go right after the set mail line - how can you send the mail if it doesn't yet know the proper config?  : ) 

    You're also missing the "e" at the end of "Updat".

    See also http://classicasp.aspfaq.com/email/how-do-i-send-e-mail-with-cdo.html 

  • Re: Problem when I press the submit button on my contact form

    Sep 18, 2008 09:29 AM|aic|LINK

     thanks for that but still.... nope.... doesnt work. it's all too complicated for me as I have never used these kind of things before. i think i will have to take a long time (which i dont have) to try and read through everything on that website you gave. Will let you know how it goes later on. thanks for your time though.

  • Re: Problem when I press the submit button on my contact form

    Sep 18, 2008 02:03 PM|steve schofield|LINK

    There isn't much we can do to provide assistance.   I adjusted the code a little so the mail configuration was at the top.  The code itself works and without having access to the server itself, I'm not sure what else we can do.  Good luck and let us know.

     

    <%

     ' declare variables

    Dim EmailFrom

    Dim EmailTo

    Dim Subject

    Dim Fullname

    Dim Email

    Dim Country

    Dim Tel

    Dim Company

    Dim Website

    Dim Message

    Dim mail

    Set mail = Server.CreateObject("CDO.Message")


    mail.Configuration.Fields.Item _

    ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2

    mail.Configuration.Fields.Item _

    ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="127.0.0.1"

    mail.Configuration.Fields.Item _

    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=8025

    mail.Configuration.Fields.Update


     

    ' get posted data into variables

    EmailFrom = "info@aicconsulting.co.uk"

    EmailTo = "info@aicconsulting.co.uk"

    Subject = "AIC Consulting Contact form"

    Fullname = Trim(Request.Form("Fullname"))

    Email = Trim(Request.Form("Email")) 

    Country = Trim(Request.Form("Country"))

    Tel = Trim(Request.Form("Tel"))

    Company = Trim(Request.Form("Company"))

    Website = Trim(Request.Form("Website"))

    Message = Trim(Request.Form("Message"))

     

    ' validation

    Dim validationOK

    validationOK=true

    If (validationOK=false) Then Response.Redirect("contact2error.htm" & EmailFrom)

     

    ' prepare email body text

    Dim HTMLBody

    HTMLBody = HTMLBody & "Full Name: " & Fullname & VbCrLf

    HTMLBody = HTMLBody & "Email: " & Email & VbCrLf

    HTMLBody = HTMLBody & "Country: " & Country & VbCrLf

    HTMLBody = HTMLBody & "Tel: " & Tel & VbCrLf

    HTMLBody = HTMLBody & "Company: " & Company & VbCrLf

    HTMLBody = HTMLBody & "Website: " & Website & VbCrLf

    HTMLBody = HTMLBody & "Message: " & Message & VbCrLf

     

    ' send email


    mail.To = EmailTo

    mail.From = EmailFrom

    mail.Subject = Subject

    mail.HTMLBody = HTMLBody

    mail.Send

     

    ' redirect to success page

    Response.Redirect("contact2.htm" & EmailFrom)

     


    %>

    Steve Schofield
    Windows Server MVP - IIS
    http://iislogs.com/steveschofield
    http://www.IISLogs.com
    Log archival solution
    Install, Configure, Forget

  • Re: Problem when I press the submit button on my contact form

    Sep 19, 2008 03:19 AM|aic|LINK

     Thank you all so much for all your help. I am guessing it has something to do with the server so will let you know how it goes once ive spoken to them again.

    Have a great day!