Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

sending a form by ASP

  • 30-10-2008 2:40pm
    #1
    Moderators, Computer Games Moderators Posts: 10,462 Mod ✭✭✭✭


    Hi guys,

    not very familiar with ASP and am trying to send a form from a website to an email address, standard submission form. When i submit the page i get a 500 error as its not running the code properly, i had it working with CDONT but it was taking ages for the form to come through so I found out on the net i should change to CDO but im kinda lost. Apart from the email address being blah@blah.com can anyone help me with what is wrong here.
    <&#37;
    ' declare variables
    Dim EmailFrom
    Dim EmailTo
    Dim Subject
    Dim Name
    Dim Address
    Dim ContactNumber
    Dim ContactMobile
    Dim Fax
    Dim DateEstablished
    Dim Comments
    
    ' get posted data into variables
    EmailFrom = Trim(Request.Form("EmailFrom")) 
    EmailTo = "[EMAIL="blah@blah.com"]blah@blah.com[/EMAIL]"
    Subject = "Contact Form"
    Name = Trim(Request.Form("Name")) 
    Address = Trim(Request.Form("Address")) 
    ContactNumber = Trim(Request.Form("ContactNumber")) 
    ContactMobile = Trim(Request.Form("ContactMobile")) 
    Email = Trim(Request.Form("EmailFrom")) 
    Fax = Trim(Request.Form("Fax")) 
    DateEstablished = Trim(Request.Form("DateEstablished")) 
    Comments = Trim(Request.Form("Comments")) 
    
    ' validation
    Dim validationOK
    validationOK=true
    If (Trim(EmailFrom)="") Then validationOK=false
    If (validationOK=false) Then Response.Redirect("error.htm?" & EmailFrom)
    ' prepare email body text
    Dim Body
    Body = Body & "Name: " & Name & VbCrLf
    Body = Body & "Address: " & Address & VbCrLf
    Body = Body & "ContactNumber: " & ContactNumber & VbCrLf
    Body = Body & "ContactMobile: " & ContactMobile & VbCrLf
    Body = Body & "Email: " & EmailFrom & VbCrLf
    Body = Body & "Fax: " & Fax & VbCrLf
    Body = Body & "DateEstablished: " & DateEstablished & VbCrLf
    Body = Body & "Comments: " & Comments & VbCrLf
    
    ' send email 
    Dim myMail
    Set myMail = Server.CreateObject("CDO.Message") 
    myMail.To = EmailTo
    myMail.From = EmailFrom
    myMail.Subject = Subject
    myMail.Body = Body
    myMail.Send 
    Set myMail= nothing
    
    ' redirect to success page 
    Response.Redirect("thanks.htm?" & EmailFrom)
    %>
    


Comments

  • Registered Users, Registered Users 2 Posts: 917 ✭✭✭Páid


    are you sure that the thanks.htm? page exists ? I would remove the question mark as it's not being used.


  • Registered Users, Registered Users 2 Posts: 21,263 ✭✭✭✭Eoin


    As Páid says, check that the thanks.htm exists. If there's a problem with the ASP, it will most likely be a 50n error of some description.


  • Moderators, Computer Games Moderators Posts: 10,462 Mod ✭✭✭✭Axwell


    eoin_s wrote: »
    As Páid says, check that the thanks.htm exists. If there's a problem with the ASP, it will most likely be a 50n error of some description.

    The thanks.htm page exists


  • Registered Users, Registered Users 2 Posts: 21,263 ✭✭✭✭Eoin


    Axwell wrote: »
    The thanks.htm page exists

    Check the action of the form that's calling that page. Could it be looking for the wrong ASP page?


  • Moderators, Computer Games Moderators Posts: 10,462 Mod ✭✭✭✭Axwell


    The action is calling the right page, however it is a 500 error I am getting, i put down 404 by mistake above.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 917 ✭✭✭Páid


    Axwell wrote: »
    The action is calling the right page, however it is a 500 error I am getting, i put down 404 by mistake above.

    Could you post the text of the error here ?


  • Registered Users, Registered Users 2 Posts: 21,263 ✭✭✭✭Eoin


    Axwell wrote: »
    The action is calling the right page, however it is a 500 error I am getting, i put down 404 by mistake above.

    Ah ok. What line does the error correspond to - is it myMail.Send by any chance?


  • Moderators, Computer Games Moderators Posts: 10,462 Mod ✭✭✭✭Axwell


    eoin_s wrote: »
    Ah ok. What line does the error correspond to - is it myMail.Send by any chance?

    this is all i get when i submit the form.. the address bar changes to the asp page and then this..

    The website cannot display the page
    HTTP 500

    Most likely causes:
      <LI id=causeSiteMaintenance>
    The website is under maintenance.
    [*]
    The website has a programming error.
    What you can try:
    [IMG]res://ieframe.dll/bullet.png[/IMG] [URL="javascript:clickRefresh()"]Refresh the page.[/URL]
    [IMG]res://ieframe.dll/bullet.png[/IMG] [URL="javascript:history.back();"]Go back to the previous page.[/URL]
    [URL="res://ieframe.dll/http_500.htm#"][IMG]res://ieframe.dll/down.png[/IMG][/URL] [URL="javascript:expandCollapse('infoBlockID', true);"]More information[/URL]
    This error (HTTP 500 Internal Server Error) means that the website you are visiting had a server problem which prevented the webpage from displaying.
    For more information about HTTP errors, see Help.


  • Registered Users, Registered Users 2 Posts: 917 ✭✭✭Páid


    Go to Internet Explorer > Tools > Internet Options > Advanced Tab (top right)

    Uncheck Show Friendly HTTP error messages and click OK.

    Try to submit the form again and it should show the text of the error. Post it here if possible.


  • Registered Users, Registered Users 2 Posts: 21,263 ✭✭✭✭Eoin


    Crap, can't remember how you turn on more detailed messages. If you're running this locally, it's somewhere in the application settings on IIS.

    Comment out the mail.send line and see if it works - could be a connectivity or permissions problem on the mailserver.

    Actually -

    1) put this at the top of the page :
    On Error Resume Next
    

    2) Comment out the redirect line

    3) At the bottom put this in:
    If err.number <> 0 Then
        Response.Write err.number & "<br>"
        Response.Write err.description & "<br>"
        Response.Write err.source & "<br>"
    End If
    

    That should give a clue what's happening


  • Advertisement
  • Moderators, Computer Games Moderators Posts: 10,462 Mod ✭✭✭✭Axwell


    eoin_s wrote: »
    Crap, can't remember how you turn on more detailed messages. If you're running this locally, it's somewhere in the application settings on IIS.

    Comment out the mail.send line and see if it works - could be a connectivity or permissions problem on the mailserver.

    Actually -

    1) put this at the top of the page :
    On Error Resume Next
    

    2) Comment out the redirect line

    3) At the bottom put this in:
    If err.number <> 0 Then
        Response.Write err.number & "<br>"
        Response.Write err.description & "<br>"
        Response.Write err.source & "<br>"
    End If
    

    That should give a clue what's happening

    Thanks Eoin,

    did that and got the following:

    438
    Object doesn't support this property or method
    Microsoft VBScript runtime error


  • Registered Users, Registered Users 2 Posts: 917 ✭✭✭Páid


    Páid wrote: »
    Go to Internet Explorer > Tools > Internet Options > Advanced Tab (top right)

    Uncheck Show Friendly HTTP error messages and click OK.

    If you do it this way you will get the line number.

    Change on error resume next to on error goto 0


  • Moderators, Computer Games Moderators Posts: 10,462 Mod ✭✭✭✭Axwell


    Páid wrote: »
    If you do it this way you will get the line number.

    Change on error resume next to on error goto 0

    When i do that i get the following:

    An error occurred on the server when processing the URL. Please contact the system administrator.


  • Registered Users, Registered Users 2 Posts: 917 ✭✭✭Páid


    Also, I think that

    myMail.Body = Body

    should be

    myMail.TextBody = Body


  • Registered Users, Registered Users 2 Posts: 21,263 ✭✭✭✭Eoin


    Nothing jumping out at me there, and I have to shoot off now.

    I would comment out all the lines and remove the comment line by line until you hit the error.


  • Registered Users, Registered Users 2 Posts: 21,263 ✭✭✭✭Eoin


    Páid wrote: »
    Also, I think that

    myMail.Body = Body

    should be

    myMail.TextBody = Body

    Actually, I use .htmlBody so that could well be the problem.


  • Moderators, Computer Games Moderators Posts: 10,462 Mod ✭✭✭✭Axwell


    Páid wrote: »
    Also, I think that

    myMail.Body = Body

    should be

    myMail.TextBody = Body

    Páid i do belive you have solved the problem, im just sending a few submissions to check but i think that was the problem.

    Cheers for the help Lads


  • Registered Users, Registered Users 2 Posts: 917 ✭✭✭Páid


    No probs. Glad you got it sorted.


Advertisement