Sending Email

J

Jerry

hi, i seem to be having problems with this code. The code stops on the Set
NewMailObj = CreateObject("CDONTS.Newmail") Your help would be greatly
appreciated.


<%@ Language=VBScript %>
<!--#include file="ADOvbs.inc"-->
<!--#include file="cdonts.inc"-->
<%Username = Cstr(Trim(Request.form("UserName")))%>
<%email = Cstr(Trim(request.form("Email")))%>
<%
Set Conn = Server.CreateObject( "ADODB.Connection" )
set oRs=Server.CreateObject("ADODB.recordset")
conn.Open "DSN=falco; uid=sa; pwd=6stang7"
strSql = "SELECT * FROM Tenant " &_
"WHERE Customerid = '" & Cstr(Request.form("UserName")) & "' " &_
"AND email = '" & Cstr(Request.form("email")) & "'"
oRS.open strSql, conn
if not ors.eof then
oRS.movefirst
do while not oRS.eof
dim NewMailObj
Set NewMailObj = CreateObject("CDONTS.Newmail")
newMailObj.From = "(e-mail address removed)"
newMailObj.To = ors("email")
newMailObj.Subject = ors("Password")
newMailObj.BodyFormat = CdoBodyFormatText
sMailBody = "Dear " & ors("Tenant") & "," & vbNewLine & vbNewLine
sMailBody = sMailBody & ors("password")
newMailObj.Body = sMailBody
newMailObj.Send
Set newMailObj = Nothing
ors.movenext
loop
end if
oRs.close
set oRS=nothing
%>


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Email</title></head>

<body>


<H2>Your message has been sent!</H2>
</BODY>

</html>
 
P

p c

Review the examples here
http://www.w3schools.com/asp/asp_send_email.asp

Then Change this line
NewMailObj = CreateObject("CDONTS.Newmail")
To this
Set newMailObj=CreateObject("CDO.Message")

Then change all lines associated the mail object to match the example
fir what you want to do.

You can probably delete this line, too.
<!--#include file="cdonts.inc"-->

..PC
 
M

Mike Mueller

CDONTS and CDOSYS are both included on 2000.

Installing CDONTS on XP or 2003 is a violation of the EULA


: What Windows server is the site on? CDONTS is supported
only on WINNT.
:
: MS replaced CDONTS woth CDO in Win 2000 and later. If you
insinst on
: using CDONTS, the admin can manually install it. But CDO
is better.
:
: For examples, see:
: http://www.w3schools.com/asp/asp_send_email.asp
:
: ..PC
:
: Jerry wrote:
:
: > hi, i seem to be having problems with this code. The
code stops on the Set
: > NewMailObj = CreateObject("CDONTS.Newmail") Your help
would be greatly
: > appreciated.
: >
: >
: > <%@ Language=VBScript %>
: > <!--#include file="ADOvbs.inc"-->
: > <!--#include file="cdonts.inc"-->
: > <%Username = Cstr(Trim(Request.form("UserName")))%>
: > <%email = Cstr(Trim(request.form("Email")))%>
: > <%
: > Set Conn = Server.CreateObject( "ADODB.Connection" )
: > set oRs=Server.CreateObject("ADODB.recordset")
: > conn.Open "DSN=falco; uid=sa; pwd=6stang7"
: > strSql = "SELECT * FROM Tenant " &_
: > "WHERE Customerid = '" &
Cstr(Request.form("UserName")) & "' " &_
: > "AND email = '" & Cstr(Request.form("email")) & "'"
: > oRS.open strSql, conn
: > if not ors.eof then
: > oRS.movefirst
: > do while not oRS.eof
: > dim NewMailObj
: > Set NewMailObj = CreateObject("CDONTS.Newmail")
: > newMailObj.From = "(e-mail address removed)"
: > newMailObj.To = ors("email")
: > newMailObj.Subject = ors("Password")
: > newMailObj.BodyFormat = CdoBodyFormatText
: > sMailBody = "Dear " & ors("Tenant") & "," & vbNewLine
& vbNewLine
: > sMailBody = sMailBody & ors("password")
: > newMailObj.Body = sMailBody
: > newMailObj.Send
: > Set newMailObj = Nothing
: > ors.movenext
: > loop
: > end if
: > oRs.close
: > set oRS=nothing
: > %>
: >
: >
: > <html>
: >
: > <head>
: > <meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
: > <title>Email</title></head>
: >
: > <body>
: >
: >
: > <H2>Your message has been sent!</H2>
: > </BODY>
: >
: > </html>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top