Pull info from database than send that info via email?

Discussion in 'ASP General' started by Kenshin, Jun 25, 2004.

  1. Kenshin

    Kenshin Guest

    Hey!

    I have another script where i pull all the information from the database and I want to send it to the person. What they do is they enter in their email, and if the email matches, than it will email them their login information.

    How do you grab the info and than use that info and put it into an email to send?

    Here is my code thus far for it:



    <%
    Function SendEmail()

    Dim myMail
    Set myMail = CreateObject("CDONTS.NewMail")
    HTML = "<!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">" & NL
    HTML = HTML & "<html>"
    HTML = HTML & "<head>"
    HTML = HTML & "<title>Login Information</title>"
    HTML = HTML & "</head>"
    HTML = HTML & "<center><b>Your Login Information</b></center>"
    HTML = HTML & "<br>Dear: "
    HTML = HTML & "<br><br>Here is your login information:"
    HTML = HTML & "<br> <b>User Name: </b>"
    HTML = HTML & "<br> <b>Password: </b>"
    HTML = HTML & "<br><br> Please print this page for your records, and keep this information in a safe place. You can always check to see if there are any updates by going to that site. When there is an update available, we will send an email alerting you of this."
    HTML = HTML & "<br><br> Thank you,"
    HTML = HTML & "<br>3B Software Team"
    HTML = HTML & "</body>"
    HTML = HTML & "</html>"

    myMail.From = ""
    myMail.To = Request.Form("email")
    myMail.Subject = "Free Update Login Information"
    myMail.BodyFormat = 0
    myMail.MailFormat = 0
    myMail.Body = HTML
    myMail.Send

    End Function
    %>

    <%
    Response.Expires = -1000 'Make sure the browser doesnt cache this page
    Response.Buffer = True 'enables our response.redirect to work

    If Request.Form("valuepassed") ="true" Then
    CheckSignUpForm
    Else
    ShowSignUpForm
    End If
    Sub CheckSignUpForm

    Dim myconn, verify, blnLoggedIn, email, objRS
    Set verify = Server.CreateObject("ADODB.Connection")
    verify.open = "Provider=SQLOLEDB.1;Password=XXX;Persist Security Info=True;User ID=XXX;Initial Catalog=XXX;Data Source=XXX"

    email = Request.Form("email")

    Set objRS = verify.execute("SELECT id,ordernum, firstname, lastname, username, pass FROM regfreeup WHERE email='" & email & "';")
    If objRS.EOF Then '''NO RECORDS MATCH. PROCEED WITH LOGIN CREATION
    blnLoggedIn = False
    Response.Redirect "http://www.microsoft.com"

    Else '''EVERYTHING PASSED CHANGE EMAIL
    blnLoggedIn = True
    (no idea how to grab that info and put it into the email up top.)

    SendEmail()
    Response.Redirect "http://www.yahoo.com"
    End If

    verify.close
    set verify = nothing

    ShowSignUpForm
    End Sub

    %>

    <% Sub ShowSignUpForm %>
    form
    <%end sub%>
    Kenshin, Jun 25, 2004
    #1
    1. Advertising

  2. Kenshin

    Jeff Cochran Guest

    On Fri, 25 Jun 2004 08:39:54 -0700, "Kenshin"
    <> wrote:

    >Hey!
    >
    >I have another script where i pull all the information from the database and I want to send it to the person. What they do is they enter in their email, and if the email matches, than it will email them their login information.
    >
    >How do you grab the info and than use that info and put it into an email to send?
    >
    >Here is my code thus far for it:


    First, do a Response.Write and make sure you're retrieving the info
    correctly. To mail it, see:

    http://www.aspfaq.com/show.asp?id=2119

    Jeff

    ><%
    >Function SendEmail()
    >
    >Dim myMail
    >Set myMail = CreateObject("CDONTS.NewMail")
    >HTML = "<!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">" & NL
    >HTML = HTML & "<html>"
    >HTML = HTML & "<head>"
    >HTML = HTML & "<title>Login Information</title>"
    >HTML = HTML & "</head>"
    >HTML = HTML & "<center><b>Your Login Information</b></center>"
    >HTML = HTML & "<br>Dear: "
    >HTML = HTML & "<br><br>Here is your login information:"
    >HTML = HTML & "<br> <b>User Name: </b>"
    >HTML = HTML & "<br> <b>Password: </b>"
    >HTML = HTML & "<br><br> Please print this page for your records, and keep this information in a safe place. You can always check to see if there are any updates by going to that site. When there is an update available, we will send an email alerting you of this."
    >HTML = HTML & "<br><br> Thank you,"
    >HTML = HTML & "<br>3B Software Team"
    >HTML = HTML & "</body>"
    >HTML = HTML & "</html>"
    >
    >myMail.From = ""
    >myMail.To = Request.Form("email")
    >myMail.Subject = "Free Update Login Information"
    >myMail.BodyFormat = 0
    >myMail.MailFormat = 0
    >myMail.Body = HTML
    >myMail.Send
    >
    >End Function
    >%>
    >
    ><%
    >Response.Expires = -1000 'Make sure the browser doesnt cache this page
    >Response.Buffer = True 'enables our response.redirect to work
    >
    >If Request.Form("valuepassed") ="true" Then
    >CheckSignUpForm
    >Else
    >ShowSignUpForm
    >End If
    >Sub CheckSignUpForm
    >
    >Dim myconn, verify, blnLoggedIn, email, objRS
    >Set verify = Server.CreateObject("ADODB.Connection")
    >verify.open = "Provider=SQLOLEDB.1;Password=XXX;Persist Security Info=True;User ID=XXX;Initial Catalog=XXX;Data Source=XXX"
    >
    >email = Request.Form("email")
    >
    >Set objRS = verify.execute("SELECT id,ordernum, firstname, lastname, username, pass FROM regfreeup WHERE email='" & email & "';")
    > If objRS.EOF Then '''NO RECORDS MATCH. PROCEED WITH LOGIN CREATION
    > blnLoggedIn = False
    > Response.Redirect "http://www.microsoft.com"
    >
    > Else '''EVERYTHING PASSED CHANGE EMAIL
    > blnLoggedIn = True
    > (no idea how to grab that info and put it into the email up top.)
    >
    > SendEmail()
    > Response.Redirect "http://www.yahoo.com"
    > End If
    >
    >verify.close
    >set verify = nothing
    >
    >ShowSignUpForm
    >End Sub
    >
    >%>
    >
    ><% Sub ShowSignUpForm %>
    >form
    ><%end sub%>
    Jeff Cochran, Jun 25, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dealkk
    Replies:
    0
    Views:
    470
    dealkk
    Jul 26, 2005
  2. Replies:
    2
    Views:
    2,139
    Mike Treseler
    Jun 28, 2006
  3. Kun
    Replies:
    1
    Views:
    306
    Arne Ludwig
    Mar 25, 2006
  4. Replies:
    2
    Views:
    103
    Bob Barrows [MVP]
    Mar 9, 2006
  5. jsd219
    Replies:
    1
    Views:
    103
    Peter Michaux
    Oct 17, 2007
Loading...

Share This Page