1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

ASP Form Trouble

Discussion in 'C#' started by Tropica, May 27, 2007.

  1. #1
    Hey!

    To cut a long story short I had a PHP form, but the client has a windows server, so i had to re-code it to ASP, i havent used asp before, but i made a form and it worked well, i was testing it on godaddy, but then uploaded it all again and now the form doesnt work

    Here is the ASP file:

    
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <% 
    Option Explicit
    Response.Expires = 0
    
    
    Dim strName
    Dim strAddress
    Dim strPostcode
    Dim strPhone
    Dim strMobile
    Dim strEmail
    Dim strHelp
    Dim strMore
    
    
    strName = Trim(Request.Form("name"))
    strAddress = Trim(Request.Form("address"))
    strPostcode = Trim(Request.Form("postcode"))
    strPhone = Trim(Request.Form("phone"))
    strMobile = Trim(Request.Form("mobile"))
    strEmail = Trim(Request.Form("email"))
    strHelp = Trim(Request.Form("help"))
    strMore = Trim(Request.Form("more"))
    
    
    Dim objMyMail1, msgBody, msgSubject
    Set objMymail1 = Server.CreateObject("CDONTS.NewMail")
    
    Dim strResponse
    
    strResponse = "Response from my site"
    
    msgSubject = strResponse
    
    
    msgBody ="<html>"
    msgBody = msgBody & "<head>"
    msgBody = msgBody & "<title>Help Request Form</title>"
    msgBody = msgBody & "<style type='text/css'>"
    msgBody = msgBody & "<!--"
    msgBody = msgBody & "p {	font-family: Arial, Helvetica, sans-serif;	font-size: 75%;	color: #333333;}"
    msgBody = msgBody & "-->"
    msgBody = msgBody & "</style>"
    msgBody = msgBody & "</head>"
    msgBody = msgBody & "<body>"
    msgBody = msgBody & "<p>This is a response From ********</p>"
    
    
    msgBody = msgBody & "<p>Name: "
    msgBody = msgBody & strName
    msgBody = msgBody & "</p>"
    
    
    msgBody = msgBody & "<p>Address: "
    msgBody = msgBody & strAddress
    msgBody = msgBody & "</p>"
    
    
    msgBody = msgBody & "<p>Postcode: " 
    msgBody = msgBody & strPostcode
    msgBody = msgBody & "</p>"
    
    
    msgBody = msgBody & "<p>Phone: "
    msgBody = msgBody & strPhone
    msgBody = msgBody & "</p>"
    
    
    msgBody = msgBody & "<p>Mobile: "
    msgBody = msgBody & strMobile
    msgBody = msgBody & "</p>"
    
    
    msgBody = msgBody & "<p>Email:<br>"
    msgBody = msgBody & strEmail
    msgBody = msgBody & "</p>"
    
    msgBody = msgBody & "<p>Help:<br>"
    msgBody = msgBody & strHelp
    msgBody = msgBody & "</p>"
    
    msgBody = msgBody & "<p>More:<br>"
    msgBody = msgBody & strMore
    msgBody = msgBody & "</p>"
    
    msgBody = msgBody & "</body></html>"
    
    
    
    objMyMail1.From = strEmail
    
    objMyMail1.To = "myemail@mail.com"
    
    
    objMyMail1.Subject = msgSubject
    objMyMail1.BodyFormat = 0
    objMymail1.MailFormat = 0
    objMyMail1.Body = msgBody
    objMyMail1.Send
    Set objMyMail1 = Nothing
    
    %>
    
    
    
    
    
    <html>
    <head>
    <title>Thank You</title>
    <style type="text/css">
    <!--
    p {	font-family: Arial, Helvetica, sans-serif;	font-size: 95%;	color: #333333;}
    -->
    </style>
    </head>
    <body>
    
    
    
    <div id="mail">
        
        
    <p>  <br><br> 
    <center>
    Thank you
    <BR><BR>
    <a href="javascript:window.close();"><u>Click here To Close This Window</u></a>
    
    
    </p>
    
    
    </body></html>
    Code (markup):

    and here is the form html code:

    
    <form action='mail.asp' method='post'>
    Name (optional): <input type='text' name='name' size=35><br><br>
    Address (optional): <input type='text' name='address' size=35><br><br>
    Postcode (optional): <input type='text' name='postcode' size=35><br><br>
    
    Telephone Number (optional): <input type='text' name='phone' size=35><br><br>
    Mobile Telephone Number (optional): <input type='text' name='mobile' size=35><br><br>
    Email Address (optional): <input type='text' name='email' size=35><br><br>
    
    How can I help?<BR>
    <SELECT NAME="help" SIZE="1">
    <OPTION SELECTED>- Please Select One -
    <OPTION>Anti Social Behaviour
    <OPTION>Drugs
    <OPTION>Bullying
    <OPTION>Weapons
    <OPTION>Hate Crime
    <OPTION>Other
    </SELECT>
    
    </P>
    <BR><BR>
    <FONT 
    color="6d1b67" size="2" font face="arial">
    <B>Please Type Your Message Below (you MUST fill in this section): </b>
    <BR>
    
    <textarea name='more' ROWS=6 COLS=30></textarea><br>
    <BR>
    <input type='submit' value='Send'>
    </form>
    
    HTML:
    I cant understand what i have done, if someone can point me in the right direction, or tell me what I have done wrong I would be so grateful

    Thanks

    :)
     
    Tropica, May 27, 2007 IP
  2. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #2
    what does it do that it does not work, I mean what error you get?

    EDIT:
    Another problem is that you do not replace characters such as ' or ", please do it in strName, strAddress, strHelp, strMore
    also allow only numbers in strPostcode, strPhone, strMobile
     
    ludwig, May 27, 2007 IP
  3. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #3
    ludwig, May 27, 2007 IP
  4. Tropica

    Tropica Notable Member

    Messages:
    2,431
    Likes Received:
    128
    Best Answers:
    0
    Trophy Points:
    230
    #4
    thats the odd thing, i get no error, the form says it is sent, but i receive no email :(

    Im not sure what you mean with the "or" ? Im totally new to asp

    With the form, it is an anonymous form, so the fields dont matter what is inserted, only the "more" section is important.

    Thanks
     
    Tropica, May 27, 2007 IP
  5. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #5
    try to use this method for sending
    in place of this
    have this
     
    ludwig, May 27, 2007 IP
  6. Tropica

    Tropica Notable Member

    Messages:
    2,431
    Likes Received:
    128
    Best Answers:
    0
    Trophy Points:
    230
    #6
    thanks for the reply, i got this error when i pressed send:

    Microsoft VBScript runtime error '800a01f4'

    Variable is undefined: 'myMail'

    /mail.asp, line 96
     
    Tropica, May 27, 2007 IP
  7. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #7
    Dim objMyMail, msgBody, msgSubject
     
    ludwig, May 27, 2007 IP
  8. mattcch2007

    mattcch2007 Peon

    Messages:
    562
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    objMyMail1.To = "myemail@mail.com"

    hi mate
    try replace it with a working email address of yours for testing purpose,
    above is a generalized one.

    :)
     
    mattcch2007, May 27, 2007 IP
  9. Tropica

    Tropica Notable Member

    Messages:
    2,431
    Likes Received:
    128
    Best Answers:
    0
    Trophy Points:
    230
    #9
    yeah i changed the email, first time i tested, i still have the same error :(
     
    Tropica, May 27, 2007 IP
  10. mattcch2007

    mattcch2007 Peon

    Messages:
    562
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #10

    hi,
    what is codes for line 96?:)
     
    mattcch2007, May 27, 2007 IP
  11. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #11
    any news you have?
     
    ludwig, May 27, 2007 IP
  12. ukcountryholidays.com

    ukcountryholidays.com Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Have them check the c:\inetpub\mailroot\queue folder - also the badmail folder and see if there are mails in there.

    If there are it may be worthwhile them restarting the Microsoft SMTP service - also check the port that Microsoft SMTP is set up to use - it might be conflicting with other mail programs on the server - so you may need to change the port number it uses to 26.
     
    ukcountryholidays.com, Jun 1, 2007 IP
  13. ukcountryholidays.com

    ukcountryholidays.com Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    also try

    Set myMail = Server.CreateObject("cdo.message")
     
    ukcountryholidays.com, Jun 1, 2007 IP
  14. ecards

    ecards Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Try this, tested.


    <%
    Dim objEmail
    Set objEmail = Server.CreateObject("Persits.MailSender")
    objEmail.Username = "username"
    objEmail.Password = "password"
    objEmail.Host = "smtp.server.com"
    objEmail.FromName= "Your Name"
    objEmail.From = "from@yourserver.com"
    objEmail.AddAddress "to@yourserver.com"
    objEmail.Subject = "Subject"
    objEmail.AddReplyTo "replyto@yourserver.com"
    objEmail.Body = "Body"
    objEmail.Send
    Set objEmail = Nothing
    %>

    :)
     
    ecards, Jun 2, 2007 IP
  15. surfnearnzone

    surfnearnzone Well-Known Member

    Messages:
    1,492
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    165
    #15
    I think you should check the above mail sending routine.

    However, I will try the code tonight and tell you. :D What's wrong with your code:)
     
    surfnearnzone, Jun 10, 2007 IP
  16. kashif.nazar

    kashif.nazar Peon

    Messages:
    52
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #16
    your code is correct, it should work.
    The possible cause is, the CDONTS will not be installed on the server where you have uploaded the files. Please confirm it from your server service provider.
     
    kashif.nazar, Jun 10, 2007 IP