Sending Mail

Bliss

Perch
This is one of the subscription scripts wrote, and I can't figure out why it won't work. Can anyone help? Note: This is an include file, and doesn't run by itself.

Code:
<%
If blnEmail = True AND strMode <> "edit" Then
Dim rsSubcriptions
Dim objCDOMail
Set rsSubscriptions = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM subscribers;"
rsSubscriptions.CursorType = 2
rsSubscriptions.LockType = 3
rsSubscriptions.Open strSQL, strCon
Do UNTIL rsSubscriptions.EOF
strEmailSubject = strLangSubjectEmailNewBlog
strEmailBody = strLangEmailHi & rsSubsciptions.Fields("subscriber_name")
strEmailBody = strEmailBody & "<br><br>" & strLangEmailBodyBlog1 & ""
strEmailBody = strEmailBody & "<br>" & strLangEmailBodyBlog2 & ""
strEmailBody = strEmailBody & "<br><br><b>" & strLangFormTitle & ": </b>" & blog_titolo
strEmailBody = strEmailBody & "<br><b>" & strLangFormText & ":</b><br>" & blog_testo
 
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
objCDOMail.From = Ublogname
objCDOMail.To = rsSubsciptions.Fields("subscriber_email")
		 objCDOMail.Subject = strEmailSubject
objCDOMail.Body = strEmailBody
objCDOMail.BodyFormat = 0
objCDOMail.MailFormat = 0
objCDOMail.Importance = 1 
objCDOMail.Send
 
rsSubscriptions.Movenext
Loop
Set objCDOMail = Nothing
rsSubscriptions.Close
Set rsSubscriptions = Nothing
 
End If
%>
 
Bliss said:
This is one of the subscription scripts wrote, and I can't figure out why it won't work. Can anyone help?

For the sake of debugging, I would insert some code just before you loop through the recordset that does a response.write of the recordset's rowcount. This would answer 2 questions: 1) is this code actually executing; and, 2) do you have any rows to process.

riley
 
riley said:
For the sake of debugging, I would insert some code just before you loop through the recordset that does a response.write of the recordset's rowcount.

I've been doing .Net for over a year now, so my ASP3/ADO is rusty. So let me clarify my previous post, which made a vague reference to the recordset's rowcount. ADO does not have a Rows collection and therefore, there is no rows.count propery like there is in .Net. For ASP3/ADO, the task can be accomplished with the following code:

rsSubscriptions.Open strSQL, strCon
Response.Write("Rows retrieved=" & rsSubscriptions.RecordCount)
Do UNTIL rsSubscriptions.EOF


It's amazing how quickly we forget. Too much information to absorb, or sinility? Probably a little of both...
riley
 
When all else fails, then your first IF statment must be failing:
If blnEmail = True AND strMode <> "edit" Then

-Dave
 
WineIsGood said:
When all else fails, then your first IF statment must be failing:
If blnEmail = True AND strMode <> "edit" Then

-Dave

The trick here is to determine whether or not the code is executing as expected or there is a problem with the Send. I would add a counter after the send and show the results, as follows:

. . .
objCDOMail.Send
iCount = iCount + 1

rsSubscriptions.Movenext
Loop

Response.Write("Emails sent = " & iCount)
. . .

If the count is 0, the code is not doing what is expected. If the count is > 0, there is a problem with the use of the CDONTS object.

riley
 
Back
Top