Results 1 to 7 of 7

Thread: Sending email using form in ASP?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Location
    flanders, nj 07836
    Posts
    110
    Does anyone know how to do a mail form within an ASP page?
    I need the page to be ASP so I can get some var's from the url or the previous form. If the file is a .asp, the submit button does nothing but refresh the page. If it's .htm(l) it works fine, but then the web server does not translate request.querystring property.

    Going a different way is fine if you can site example or resources. Thanks people!

    I don't want to use MAILTO url's because i'm looking for browser only independency (big work) lol

    harry


  2. #2
    Hyperactive Member Kagey's Avatar
    Join Date
    Sep 2000
    Location
    The Wilderness of New Brunswick
    Posts
    294

    hey

    hey,

    to mail something in asp, you need a mail component. if you have iis installed there is probably a component already installed.

    if you want an example or more information, just shoot me an email.

    later


  3. #3
    Junior Member
    Join Date
    Nov 2000
    Posts
    20

    Arrow Here is how to mail


    Hi,
    To enable mailing facility on your web page you need to use the CDONTS object. This would only be possible if you are working on NT server and you have IIS installed.

    here is one way of doing what you want

    make two pages acceptinfo.htm and mail.asp
    in the acceptinfo.htm page accept the desired information such as To, From, Subject, CC ,Body . Call the mail.asp file from this acceptinfo.htm form when the user submits the page. U have to use method = post for this code to work

    code in mail.asp should be as follows:

    ********************* code follows ***************

    to=request.Form("to field")
    from=request.form("from field")
    ...similarly for subject,cc,body fields

    mymailobj=server.createobject("Cdonts.newmail")
    mymailobj.send to,from,message,body,cc

    ********************** code end *******************

    this code would send the mail to the user specified in the to field of the form.

    Bye for now and just mail for any further qeuries

    happy programming!
    Bye

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Location
    flanders, nj 07836
    Posts
    110
    Does anyone recommend a good ASP how to book.. like a tips and tricks, or reference for IIS 5.0 progys?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Location
    flanders, nj 07836
    Posts
    110
    This does not solve my problem. I need the initial page to be an ASP or I need a way to capture a querystring within an html file. Here is the sinerio.

    Clients go to an HTML pages, and login to an ASP page. (backend is IIs5.0, vb 6.0 sp4 activex dll, and SQL)
    from the ASP page (where a hidden var of CUSTNUM='XXXXXX') I need a way for this ASP to get that custnum into either another html or asp that can then email.

  6. #6
    Hyperactive Member Kagey's Avatar
    Join Date
    Sep 2000
    Location
    The Wilderness of New Brunswick
    Posts
    294

    ok here

    here is code for a page that has a form and submits all in one. It detects if there is already stuff in the form collection and if there isnt it shows the mail form, if there is it submits the info and shows a confirmation page.

    Code:
    <%@ Language=VBScript %>
    <HTML>
    <HEAD>
    <title>hey there</title>
    </HEAD>
    
    <% IF Request.form = "" THEN %>
    
    The following is the email form.
    <p>
    <form Method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>" name="frmEmail">
    <p>email to send to:<BR>
    <input type="text" name="toemail"></p>
    
    <p>From Address:<BR>
    <input type="text" name="fromemail"></p>
    
    <p>Subject:<BR>
    <input type="text" name="subject"></p>
    
    <p>MessageBR>
    <textbox name="message"></textbox></p>
    
    <input type="submit" value="Send" name="submit">
    </form>
    <% Else %>
    <%
    fromWho = TRIM( Request.Form( "fromemail" ) )
    toWho = TRIM( Request.Form( "toemail" ) ) 
    Subject = TRIM( Request.Form( "subject" ) )
    Body = TRIM( Request.Form( "message" ) )
    
    SET myMail = Server.CreateObject("CDONTS.Newmail")
    myMail.From = fromWho
    myMail.To = toWho
    myMail.Subject = Subject
    myMail.Body = Body
    myMail.Send
    SET myMail = Nothing
    
    %>
    <h2>Success!</h2>
    <p>Email has been successfully sent.
    <% END IF %>
    
    </BODY>
    </HTML>
    you can attach any info you want onto the body by concantenating the value to the body.

    you can retrieve anthing from the querystring and include it as an hidden field in the form, then request it from the form.

    hope this helps.

    Kyle

  7. #7

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Location
    flanders, nj 07836
    Posts
    110
    I'm getting failure on the create object.. How do I get that object on my server?

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