Previous Next

Thread: Converting from ObjMail to .asp Mail Component

Last post 11-12-2008 9:32 AM by tomkmvp. 6 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (7 items)

Sort Posts:

  • 09-15-2008, 8:13 AM

    Converting from ObjMail to .asp Mail Component

    Need help...

    I 'inherited' a website with an .asp driven login page.  When a password is entered, the asp script checks the login.mdb file for an e-mail match and, if one is found, it generates an e-mail and sends to the address it matched.  An incorrect e-mail entry generates the "We're sorry..." response. 

    I'm being told that the ObjMail component we've used for many years is no longer supported by our host and that I need to now use the asp mail component.  I didn't write this particular piece of ObjMail code so am at a loss as to how to make the conversion.to the .asp mail component

    Any help offered would be most appreciated

    The ObjMail file from the current system...
    -----------------------------------------------------------------------------------

    <%Response.Buffer=TRUE%>
    <%
    'Here is the connection string
     Set conn = server.createobject("adodb.connection")
    'This connection uses JET 4.  It is the preferred method of connecting to an access database
     DSNtemp = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("../login.mdb")
    'If you cant use JET then comment out the line above and uncomment the line below
     'DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("../login.mdb")
     conn.Open DSNtemp

    'Get information from the lost password form
     uid = Request.Form("T1")

     SQL = "Select * From users Where uid = '" & uid & "'"
     Set RS = Conn.Execute(SQL)

    'Check to make sure that the users email exists.  If it does, email it to the user
     If NOT RS.EOF Then

     Dim mytxt
     mytxt = "Here is your password: "
     Dim ObjMail
     Set ObjMail = Server.CreateObject("CDONTS.NewMail")
    'If the email address exists then the info is sent here
     ObjMail.To = RS("uid")
    'The email address below will appear in the from line of the message that is sent to the user
     ObjMail.From = "Scoutmaster@aol.com"
     ObjMail.Subject = "Lost Password"
    'Send the user the lost password
     ObjMail.Body = mytxt & vbcrlf&_
     RS("pwd")
     ObjMail.Send
     Set ObjMail = Nothing

      x = "Thank you.  Your password will be sent to the e-mail address you entered."

     Else

    'If the entered email addrees does not exist in the database tell the user
      x = "We're sorry.  The e-mail address you entered is not in our database.  Please return to the Home Page and contact the Assistant Scoutmaster for help."

     End If
    %>

    <html>
     <head>
       <title>Lost Password</title>
          <link rel="stylesheet" type="text/css" href="../../troop_683.css">
    </head>

       <body>
         <center><%=x%></center>
       </body>
    </html>


    The .asp mail component provided by 1&1 Hosting
    -----------------------------------------------------------------------------------

    <% @LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>

    <%
    Set Mail = Server.CreateObject("SMTPsvg.Mailer") 'create an Asp mail component.
    Mail.FromName   = "1&1 Test"
    Mail.FromAddress= Request.Form("email")
    Mail.RemoteHost = "mrelay.perfora.net" ' The mail server you have to use with Asp Mail
    Mail.AddRecipient "ABCDE Company", "hello@justonedomain.com"
    Mail.Subject    = "Website - Info Request"
    Mail.BodyText   = Request.Form("info")
    if Mail.SendMail then
     Response.Write "Your mail has already been sent..."
    else
     Response.Write "Mail send failure. Error was " & Mail.Response
    end if
    %>

    <body>
    <p>Thank You!!<br>
    </body>
    </html>

  • 09-15-2008, 8:47 AM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Lawrenceville, NJ
    • Posts 4,070
    • IIS MVPs

    Re: Converting from ObjMail to .asp Mail Component

    Here's the relevant section converted for you ...

    Dim mytxt
    mytxt = "Here is your password: "
    Dim ObjMail
    Set ObjMail = Server.CreateObject("SMTPsvg.Mailer")
    'If the email address exists then the info is sent here
    ObjMail.AddRecipient RS("uid"), RS("uid")
    'The email address below will appear in the from line of the message that is sent to the user
    ObjMail.FromName = "Scoutmaster@aol.com"
    ObjMail.FromAddress = "Scoutmaster@aol.com"
    ObjMail.RemoteHost = "mrelay.perfora.net" ' The mail server you have to use with Asp Mail
    ObjMail.Subject = "Lost Password"
    'Send the user the lost password
    ObjMail.BodyText = mytxt & vbcrlf & RS("pwd")
    ObjMail.SendMail
    Set ObjMail = Nothing

  • 09-15-2008, 10:37 AM In reply to

    Re: Converting from ObjMail to .asp Mail Component

    Thanks tomkmvp.  Works like a charm!

     

  • 11-12-2008, 2:39 AM In reply to

    Re: Converting from ObjMail to .asp Mail Component

    Hope you can help with this one as well.  My site uses a very simple html script (see below) to generate group e-mails.  While we were a small Scout Troop, the script worked fine, however the string is limited to 256 characters so as we grew (and the e-mail list grew) we bump up against the character limit and the script fails.   Is there a  asp script, javascript, etc., or method we might employ to overcome this limit?

    PS  We tried to interest the group in using Google Groups or the like but there was incredible resistance...

    <a href="mailto:
    name@google.com,
    name@msn.com,
    name@cox.net,
    name@earthlink.net,
    name@yahoo.com,
    name@verizon.com
    name@netzero.com,
    name@harvard.edu,
    etc.etc@aol.com
    "><b>All Scoutmasters</b>
    </a>

  • 11-12-2008, 4:36 AM In reply to

    Re: Converting from ObjMail to .asp Mail Component

    Looks like html tag limit, nothing you can do. why not server side scripting from asp, asp.net etc?

    Cheers,
    Bernard Cheah
  • 11-12-2008, 9:27 AM In reply to

    Re: Converting from ObjMail to .asp Mail Component

    Thanks for your interest!  The mailto string is limited to 256 characters so as the e-mail list grew it bumped up against the character limit.  For large strings, where the number of e-mail address total up to more than 256 characters, the mailto script fails.   Is there a cleaver asp script or method that you are aware of that I might employ to overcome this issue?  I need a cut 'n paste solution as I'm not particularly code savvy.  Thnaks again!

  • 11-12-2008, 9:32 AM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Lawrenceville, NJ
    • Posts 4,070
    • IIS MVPs

    Re: Converting from ObjMail to .asp Mail Component

    You already have most of the code above.  Now you just need:

    ObjMail.AddRecipient "name@google.com"
    ObjMail.AddRecipient "name@msn.com"
    ObjMail.AddRecipient "name@cox.net"

    ... etc

Page 1 of 1 (7 items)
Page view counter