This topic is locked

Mass email error

8/23/2010 9:57:22 AM
ASPRunnerPro General questions
S
StevePearce author

Hi,
Below is the code I am using on the afteradd event on an add page, this idea is that you enter the subject and email body on the add page, and it will send to the distrution list in the table Test. The email sends fine, however it redirects to an error page:
CODE:
'** Send email with new data ****

' do not forget to setup email parameters like From, SMTP server etc

' on 'Security->User login settings' dialog

Response.Flush

set data = dal.Table("Test").QueryAll()

while not data.eof

' send the email

Dim htmlMsg

set params = CreateObject("Scripting.Dictionary")

params("to")= data("EMAIL")

params("cc")=""

params("subject")= values("EMAIL_SUBJECT")
htmlMsg = values("EMAIL_BODY")
params("htmlbody")= htmlmsg
params("charset")="UTF-8"

set result = runner_mail(params)

if not result("mailed") then

response.write result("message")

response.flush

end if

data.MoveNext

wend

data.close: data=nothing
ERROR SHOWN:
Microsoft VBScript runtime error '800a005b'
Object variable not set: 'data'
/admin/EmailCommunication_add.asp, line 0
Please help if you can.
Thanks

Steve

A
ann 8/23/2010

Steve,
you have an error in the following line:

data.close: set data=nothing
P
Philip 8/23/2010



Hi,
Below is the code I am using on the afteradd event on an add page, this idea is that you enter the subject and email body on the add page, and it will send to the distrution list in the table Test. The email sends fine, however it redirects to an error page:
CODE:
'** Send email with new data ****

' do not forget to setup email parameters like From, SMTP server etc

' on 'Security->User login settings' dialog

Response.Flush

set data = dal.Table("Test").QueryAll()

while not data.eof

' send the email

Dim htmlMsg

set params = CreateObject("Scripting.Dictionary")

params("to")= data("EMAIL")

params("cc")=""

params("subject")= values("EMAIL_SUBJECT")
htmlMsg = values("EMAIL_BODY")
params("htmlbody")= htmlmsg
params("charset")="UTF-8"

set result = runner_mail(params)

if not result("mailed") then

response.write result("message")

response.flush

end if

data.MoveNext

wend

data.close: data=nothing
ERROR SHOWN:
Microsoft VBScript runtime error '800a005b'
Object variable not set: 'data'
/admin/EmailCommunication_add.asp, line 0
Please help if you can.
Thanks

Steve


Steve,
I guess that's it:

instead of
Dim htmlMsg

set params = CreateObject("Scripting.Dictionary")

params("to")= data("EMAIL")

params("cc")=""

params("subject")= values("EMAIL_SUBJECT")
put

Dim htmlMsg

set params = CreateObject("Scripting.Dictionary")

params("to")= values("EMAIL")

params("cc")=""

params("subject")= values("EMAIL_SUBJECT")
Regards,

Philip