Results 1 to 15 of 15

Thread: Need a Server page to e-mail me

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2002
    Posts
    242

    Need a Server page to e-mail me

    Im strictly a client side developer but now Im doing something personal. So I need to do a server side function. Basically, all I need to do is take the info from the submited form and mail it to my e-mail address. I dont need any validation cause Im gonna do all that client side and none of this info is going into a database. I just need to know how to make an ASP that will do this. I want to do this server side to avaid the client side hassles with mailto: and the dialog box and all. So all I need is some ASP code that will say:



    Hey, take this form info and mail it to javans e-mail adress and make sure its in text/plain format.


    Thats all I need. I dont mind any cut and paste code, so please give me something. I wouldnt normally ask someone to "do my job" but I figured this is easy enough where its just a quick snippet of code (although I could be wrong). Please, give me the FULL code that I need to use as I will be using that as my form action url. Thanks in advance.

  2. #2
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    If you have ISS4-5 then you have access to the Collaboration Data Objects for NT Server, also known as CDONTS.

    The example below shows a simple way of using it.

    Code:
    <%
        Dim MyBody
        Dim MyCDONTSMail
    
        Set MyCDONTSMail = Server.CreateObject("CDONTS.NewMail")
        With MyCDONTSMail
          .From= "[email protected]"
          .To= "[email protected]"
          .Subject="This is a Test"
          .Body= "A Bunch Of Text"
          .Send
        End With
        set MyCDONTSMail=Nothing
    %>
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2002
    Posts
    242
    YEah, but.... I need to capture the data from my form. I dont see in that code it catching the data on the form. I just need it to grab that data and e-mail it to my e-mail adress

  4. #4
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089
    Use the request.form collection

    Code:
    UserEmail = request.form("Emailfieldname")

  5. #5
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    Oh sorry, yeah, I forgot about that.

    VeryJonny is right. varname = request.form("elementname") if your using POST as the method or varname = request.querystring("elementname") if you are using GET.
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Feb 2002
    Posts
    242
    So you're telling me that I only have to use that one line of code?! I dont need anything else?



    UserEmail = request.form("Emailfieldname")


    what do I save it as?.asp?

    Also, The e-mailfield name is my e-mail address?

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Feb 2002
    Posts
    242
    Guys, I really apreciate your help. But Im really a dummy when it comes to server side programming. Please, show me the complete code and explain it to me as you would a child

  8. #8
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    hi

    first.htm

    Accept email of user who sends you the email.

    submit this form to say page Process.asp

    Process.asp contains all the code above.

    in Process.asp you use request.querystring if u have used get method in the first.htm - form else you use request.form to get the email address of the user.

    Your email email can be hard coded in the .To part of the code.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Feb 2002
    Posts
    242
    Thanks, but the client is not going to e-mail me. They are gonna fill out a form on my website, then I want that info from that from to go to the server where it grabs that info and e-mails it to my address. I know I can just have it e-mail me from the client but then you have the dialog box come alerting the client. I dont want that.

    veryjonny, Im sorry but your last post confused me even more. Could you just put the code all together for me and just show me how to post it up and where I need to put my e-mail address in it?
    Thanks

  10. #10
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089
    sorry for confusing you.

    First a clarification now. You are making this VB or asp/html pages?

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Feb 2002
    Posts
    242
    this is for an HTML form submiting the form info back to the server. I am completely a client side developer, so I know nothing of server side processing. No even something as simple as taking the form data and e-mailing it to my web address. So yes, it is for html/asp. I just need a simple asp page that takes the form data and e-mails it to my e-mail adress. I dont need any validation because Im doing all that on the client. Thanks

  12. #12
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    hi

    Do you know the action part (attribute) set it to the asp page where the processin gwould take place (say Process.asp) and set the method = post.

    Now in the form you have textboxes, comboboxes and other things. to collect this data we use request.form collection like this:

    Code:
    mname = request.form("FieldnameMname")
    'you collect all the data similarly
    
    'now say this data needs to be emailed to you then use:
        Dim MyBody
        Dim MyCDONTSMail
    
        Set MyCDONTSMail = Server.CreateObject("CDONTS.NewMail")
        With MyCDONTSMail
          .From= "Webform@unknown" 'since you do not know who submitted it
          .To= "[email protected]"
          .Subject="Web form submitted"
          .Body= mname & allthe other variables
          .Send
        End With
        set MyCDONTSMail=Nothing
    Hope this helps

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Feb 2002
    Posts
    242
    thank you very much. for the:

    mname = request.form("FieldnameMname")

    do I have to write this over for each field on my form


    for instance, lets sayI have two text inputs:

    <input type="text" name="firstname" />
    <input type="text" name="lastname" />

    do I put

    fame = request.form("firstname")
    lame = request.form("lastname")

    or could I just send myself the whole form if I had:

    <form name="infoform">


    could I just put:

    mname = request.form("infoform")

    also, why do I have to dim MyBody. I dont see it used anywhere in the code. Thanks again

  14. #14
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    hi

    Sorry about the dim there is no need to dim mybody unless you want add (concatenate all the form data into one variable and assign it to body of the messge in the line .body = MybOdy

    Also yes you will need to request.form for ALL the fieldnames in the form.An alternative would be:

    Code:
    mybody = ""
    for each i in request.form
        mybody = mybody & vbcrlf & i & " = " & request.form(i) & "<br>"
    next
    
    'now mybody contains all the name = value pair of your form

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Feb 2002
    Posts
    242
    thanks for all your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width