Sending Mail

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 & “

” & strLangEmailBodyBlog1 & “”
strEmailBody = strEmailBody & “
” & strLangEmailBodyBlog2 & “”
strEmailBody = strEmailBody & “

” & strLangFormTitle & “: ” & blog_titolo
strEmailBody = strEmailBody & “
” & strLangFormText & “:
” & 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
%>
[/CODE]

[QUOTE=Bliss]
This is one of the subscription scripts wrote, and I can’t figure out why it won’t work. Can anyone help?
[/QUOTE]

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

[QUOTE=riley]
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.
[/QUOTE]

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

I’ve already tried that. The script executes, but I never get the mail.

Do you want the code in ASP.NET or regular ASP3?

Regular ASP.

[QUOTE=Bliss]
Regular ASP.
[/QUOTE]

Well, it took me a while, but I finally found it.

Dim rsSubcriptions

should be

Dim rsSubscriptions

riley

Hmm, I fixed that now, but it still doesn’t work…

When all else fails, then your first IF statment must be failing:
If blnEmail = True AND strMode <> “edit” Then

-Dave

[QUOTE=WineIsGood]
When all else fails, then your first IF statment must be failing:
If blnEmail = True AND strMode <> “edit” Then

-Dave
[/QUOTE]

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

Ahh, it works now, but only to my hotmail address. Is JodoHost’s mail server being blocked?

You can’t send an email from your script to a jodohost email address but to hotmail email addresses?

No, I have an email at www.gawab.com and it doesn’t work. I seem to get other emails just fine at this address.