SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)

    Question Please Help - Sending email with ASP

    Can somebody please help me?

    I need a way to send an email using a normal HTML form and then taking those values and sending them to myself.

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    This should do the trick. Just replace the to, from, subject, and body variables to what you need.
    Code:
    <%
    Dim oMail
    Set oMail = Server.CreateObject("CDONTS.NewMail")
    oMail.to = "you@yourdomain.com"
    oMail.from = "someone@other.com"
    oMail.subject = "Contact details"
    oMail.body = "hello!"
    oMail.send
    Set oMail = Nothing
    %>

  3. #3
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    thank you

  4. #4
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The script below is more configurable. It leaves you free if you want to add more fields(like subject or user's email) in your HTML form.

    Code:
    <%
    Dim oMail, oTo, oFrom, oSubject, oBody
     
    'You can add your email here or from a form field.
    oTo = "you@yourdomain.com"
     
     
    'This value can be set as any email or retrieve it from a form
    'if you allow your visitors to enter their email.
    oFrom = Trim(Request.Form("usrEmail"))
     
     
    'This value can be set as any string or retrieve it from a form
    'if you allow your visitors to enter subject for their email.
    oSubject = Trim(Request.Form("usrSubject"))
     
     
    'This value can be set as any string or retrieve it from a form
    'if you allow your visitors to enter message for their email.
    oBody = Trim(Request.Form("usrBody"))
     
     
    Set oMail = Server.CreateObject("CDONTS.NewMail")
    With oMail
    .to = oTo
    .from = oFrom
    .subject = oSubject
    .body = oBody
    .send
    End With
    Set oMail = Nothing
     
    %>
    The benefit is that this can be used anywhere without much modifications. If you want only a particular email in To or From section then just remove everything after the equal sign(=) & enter the email enclosed in double quotes("). Also, the main benefit is that you can insert the message that user send in your own template like:

    Code:
    <%
    oBody = "This message was sent to you from your website. Blah Blah...." & vbCrlf
    oBody = oBody & Trim(Request.Form("usrBody")) & vbCrlf
    oBody = oBody & "More here..........................."
    %>
    Gives you the option to have a user specified subject etc. You can add more fields & functionality according to you.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!


Bookmarks

Posting Permissions

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