Link to home
Create AccountLog in
Avatar of baxtalo
baxtalo

asked on

CDO.Message.1 error '8004020c'

I am sending a broadcast message to a mailing list from my Access Database. All recipients receive it, and it also writes to my database. After the submission I would like to be redirected to ThankYou1.asp, but instead I receive this error message:

CDO.Message.1 error '8004020c'
At least one recipient is required, but none were found.
/Broadcast_send.asp, line 43

Can anyone pleas help? Please see the attached code. Thank you...
P.S. I modified this from CDONTS to CDO. With CDONTS it was working fine, but after I I changed to CDO I get this error message.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("/NOCC/DB/NOCCUsers.mdb") & ";"
objConn.Open

strMessage = request.Form("Message")
strMessage = replace(strMessage,"'","''")
strMessage = replace(strMessage,vbCrLf,"<br />")
strSubject = request.Form("Subject")
strPersonAddedOn = request.Form("PersonAddedOn")
strComputerName = request.Form("ComputerName")
strLoggedBy = request.Form("LoggedBy")
strLog = request.Form("Log")

'create connection object
Set MesIns=CreateObject("ADODB.Command")
MesIns.ActiveConnection=objConn
MesIns.commandtext = "insert into Broadcast (Subject, PersonAddedOn, Message, ComputerName, LoggedBy, Log) VALUES (?,?,?,?,?,?)"
MesIns.Parameters.Append MesIns.CreateParameter("@Subject", 200, 1, 255, strSubject)
MesIns.Parameters.Append MesIns.CreateParameter("@PersonAddedOn", 200, 1, 255, strPersonAddedOn)
MesIns.Parameters.Append MesIns.CreateParameter("@Message", 200, 1, 555, strMessage)
MesIns.Parameters.Append MesIns.CreateParameter("@ComputerName", 200, 1, 255, strComputerName)
MesIns.Parameters.Append MesIns.CreateParameter("@LoggedBy", 200, 1, 255, strLoggedBy)
MesIns.Parameters.Append MesIns.CreateParameter("@Log", 200, 1, 255, strLog)
MesIns.Execute

Set sqlMailList = CreateObject("ADODB.Command")
sqlMailList.ActiveConnection=objConn
sqlMailList.Prepared = true
sqlMailList.CommandText = "SELECT PagerEmail FROM EWR_Pagers"
set rsMailList = sqlMailList.execute

while not rsMailList.eof

Dim myMail
Set myMail = Server.CreateObject ("CDO.Message")
myMail.From = "NOCC@coair.com"
myMail.To = rsMailList("PagerEmail")
myMail.Subject= Request.Form("Subject")
myMail.HTMLBody = Replace(Request.Form("Message"), vbCrLf, "<br />") & " <br />Sent by " & Request.Form("LoggedBy") & "<br /> "
myMail.Send

rsMailList.movenext
wend
set myMail=nothing
Response.Redirect "ThankYou1.asp"

rsMailList.Close()
Set rsMailList = Nothing
%>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of baxtalo
baxtalo

ASKER

Yes, you were right. I opened the database and noticed that two recipients didn't have their pager addresses entered. I will make it a mandatory field on the page where new recipients are added to the distribution list.
Thank you very much.