Formail.asp - Using this file to emial form data.

Discussion in 'Classic ASP' started by ASP_Newbie, Oct 29, 2007.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi, I have seen some other post about this. I am still having problems though.

    BrainJar Formail.asp file:
    '- Customization of these values is required, see documentation.

    referers = Array()
    mailComp = "ASPEMail"
    smtpServer = "localhost"
    fromAddr = "[email protected]"

    '- End required customization section.



    Form:
    <form action=/formmail.asp method=post>
    <font face="Arial, Helvetica, sans-serif" size=2>
    <font face="Verdana, Arial, Helvetica, sans-serif" color=#333333 size=1>First Name:</font>
    <input id=name size=22 name=Fname>
    <font face="Verdana, Arial, Helvetica, sans-serif" color=#333333 size=1>Last Name:</font>
    <input size=22 name=Lname>
    <font face="Verdana, Arial, Helvetica, sans-serif" color=#333333 size=1>E-mail Address:</font>
    <input size=22 name=email>
    *All Fields Required
    <p align=center>
    <input type=submit value=Submit>
    <input type=reset value=Clear> </p>
    <div align=center><font face="Verdana, Arial, Helvetica, sans-serif" size=1>We Protect Your Information:<a href="/t-privacy.aspx">Privacy Policy</a></font>

    <input type=hidden [email protected] name=_recipients>
    <input type=hidden value=Fname,Lname,email name=_requiredFields>
    </div></form>


    This is the beginning of a FormMail.asp suggested via your forums. I made these adjustments and setup the form up accordingly. When I submit the info it directs me to a "page not found" page, but says ".../formail.asp" in my address bar. So I used the "_redirect" to make it go to a particular page. That didn't work either, same problem. So now I am not really sure what to do.

    Thanks [​IMG]
     
  2. Are you absolutely new to ASP?

    Do you have the proper ASP delimiters?
    For the code sections...

    Also...Something you really should do is study about making ASP version 3 xHTML compliant.
    For example, wrapping your form section IDs in quotes.
    i.e. <form action="formmail.asp" method="post">

    I'm not a big fan of that old Brainjar ASP example and have written code for a lot of the DASP customers...
    So if you get stuck let me know, I'll write a Contact e-mail page for you if you need it, in ASP or ASP.NET.
    Salute,
    Mark

    PS - If you do end up needing my help post again here or contact me:
    http://sdknuts.net/contact/
     
  3. I am using ASPdotnetstorefront and when I use "quotes" it removes them after updating.

    I basically want an "Opt-In" form:

    First Name:
    Last Name:
    Email:

    Then that goes to whatever email address. If you have a better code, please let me know.

    I appreciate this very much. [​IMG]
     
  4. You can either use something as follows:
    <form ACTION='<%=Request.ServerVariables('SCRIPT_NAME')%>' method=post> in your exisiting form,to post back to the same page.

    But there are easier options.Using the CDO component instead!

    You can do something like (Make appropriate changes):

    <%
    set objMessage = createobject('cdo.message')
    set objConfig = createobject('cdo.configuration')

    Dim ToAddress
    ToAddress= '[email protected]'

    if(Request.Form('email') <>'' and Request.Form('Lname') <> '' and Request.Form('Fname') <>'') Then

    ToAddress=Request.Form('email')
    ' Setting the SMTP Server
    Set Flds = objConfig.Fields
    Flds.Item('http://schemas.microsoft.com/cdo/configuration/sendusing') = 2
    Flds.Item('http://schemas.microsoft.com/cdo/configuration/smtpserver') = 'localhost'
    Flds.update


    Set objMessage.Configuration = objConfig
    objMessage.To = ToAddress
    objMessage.From = '[email protected]'
    objMessage.Subject = 'Dear' + Request.Form('Lname') +' '+ Request.Form('Fname')
    objMessage.TextBody = 'Congratulation' & VbCrLf & 'If you receive this is, your mail component works'
    objMessage.fields.update
    objMessage.Send

    Response.write 'Mail sent...'

    set objMessage = nothing
    set objConfig = nothing
    Else

    'Do Something....

    End If
    %>
    <form ACTION='<%=Request.ServerVariables('SCRIPT_NAME')%>' method=post>
    <font face='Verdana, Arial, Helvetica, sans-serif' color=#333333 size=1>First Name:</font>

    <input id=name size=22 name=Fname>

    <font face='Verdana, Arial, Helvetica, sans-serif' color=#333333 size=1>Last Name:</font>

    <input size=22 name=Lname>

    <font face='Verdana, Arial, Helvetica, sans-serif' color=#333333 size=1>E-mail Address:</font>

    <input size=22 name=email>


    *All Fields Required
    <p align=center>
    <input type=submit value=Submit>
    <input type=reset value=Clear> </p>
    <div align=center><font face='Verdana, Arial, Helvetica, sans-serif' size=1>We Protect Your Information:
    <a href='/t-privacy.aspx'>Privacy Policy</a></font>


    </form>

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  5. I used this line in the form:

    <form action=
    <%
    Response.Write "Virtual path Server Variable=" &amp; Request.ServerVariables("SCRIPT_NAME")
    Response.End()
    %>
    method=post>

    The code still shows. Remember that all quotes get knocked out, I am working with ASPdotNetStorefront interface. This messes with the code above.

    I used all the code from <% to %> and pasted that into my empty formail.asp file. But after all is said and done, nothing works. I hit submit and I hit Clear, but my info stayed in the fields and nothing happened.

    [​IMG]


    Post Edited (ASP_Newbie) : 10/30/2007 4:09:24 PM GMT
     
  6. I know nothing of ASPdotNetStorefront or why it's stripping your code.
    Salute,
    Mark
     
  7. So I replace my ASP code in the formail to everything and including the <% %>?

    Then set up my form to match. This should workwith ASPdotnetstorefront?
     
  8. The form doesn't like this line:


    <form ACTION="<%=Request.ServerVariables("SCRIPT_NAME")%>" method=post>
    It show " method=post, that is suppose to be hidden.

    Thanks,
    Dan
     
  9. If you changing the form input elements,you may have to change the code within <% %> accordingly.If you see I am using Request.Form('email'),Request.Form('Lname') and Request.Form('FName') in the code,which are the values for the name attribute for your input fields in the form.

    Have you tried using the code as it is?I did and it works fine.

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  10. When you use <%=Request.ServerVariables("SCRIPT_NAME")%>


    ...With ASP it should return the virtual path to the present page being executed, or an application.


    Run some standard ASP debug tests on that page.


    For example, before the form put that same Server Variable above the form.
    Then below that put an Response.End()
    ...Which will halt the rest of the page, for testing.

    You can even dress your Variable up for the test...
    <%
    Response.Write "Virtual path Server Variable=" &amp; Request.ServerVariables("SCRIPT_NAME")
    Response.End()
    %>
     
  11. Can you explain how this relates to AspDotNetStorefront? Are you modifying one of the storefront pages with your own code? But first of all, is the page containing your form an ASP page with a .asp extension?


    Aristotle

    DiscountASP.NET
    www.DiscountASP.NET
     
  12. I did do it just like yours. The element that goes into the form does stay that way do to the aspdotnetstorefront interface.

    The form doesn't like this line:



    <form ACTION="<%=Request.ServerVariables("SCRIPT_NAME")%>" method=post>
    It shows " method=post, that is suppose to be hidden.
    How do I get the interface to take to this line?


    It seems to only strip the quotes, but in the process makes other code change. Unless it is put in right without quotes, it becomes very touchy.

    Thanks,
    Dan



    Post Edited (ASP_Newbie) : 10/31/2007 2:15:36 AM GMT
     
  13. Thanks for the script its great. However, after I hit the "Submit" button, I get the "Mail Sent..." message, but never receive an email at the address I setup in the script.

    Any ideas? Is there something I need to configure on the server?

    Thanks!
     
  14. Bruce

    Bruce DiscountASP.NET Staff

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page