Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > ASP CDO
|
ASP CDO As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP CDO section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 13th, 2004, 11:19 PM
Authorized User
 
Join Date: Sep 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default CDO.Message.1 (0x8004020C) At least one recipient

Hi,
I am a newbie for ASP and I am running a simple asp file which retrieves email addresses from the database and collects the result into a string.
Once the string is availbel i am using it to send e-mail using CDO.The program is sending e-mail to everyuser in the string it has collected.everything is ok.But its showing an error page which i don't want to see.the error is CDO.Message.1 (0x8004020C)
At least one recipient is required, but none were found.

This is my program.Please help.

<%@ Language=VBScript %>
<%
str="z687606,z682045,"
str= REplace(trim(str)," ","")
str1=split(str,",")
Dim objConn ' Connection Name
Dim strConn ' Connection String
Dim objRS ' Recordset Variable
Dim strSQL ' variable for SQL statement
Dim intTotalColumns
Dim intCounter
Const adOpenStatic = 3
Const adLockReadOnly = 1
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Server.MapPath("users.mdb") & ";"
objConn.Open strConn
dim kk
For i=0 to Ubound(str1)
strSQL = "SELECT Email FROM CRPR_USERS where UNAME='" & str1(i) & "'"
objRS.open strSql, objConn, adOpenStatic, adLockReadOnly
do while not objRS.EOF
kk= kk & objRS("Email") & ","
objRS.MoveNext
loop
objRS.Close
Next
response.write "str is --------" & kk
objConn.Close
Set objConn = Nothing
kk= REplace(trim(kk)," ","")
kk=split(kk,",")


Dim iMsg
Dim iConf
Dim Flds
Dim strHTML
Const cdoSendUsingPort = 2
For i=0 to Ubound(kk)
set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields

With Flds
.Item("http://schemas.microsoft.com/cdo/co...ation/sendusing") = cdoSendUsingPort
'ToDo: Enter name or IP address of remote SMTP server.
.Item("http://schemas.microsoft.com/cdo/co...tion/smtpserver") = "smtp.mycompany.com"
.Item("http://schemas.microsoft.com/cdo/co...nnectiontimeout") = 10
.Update
End With
strHTML = "<HTML>"
strHTML = strHTML & "<HEAD>"
strHTML = strHTML & "<BODY>"
strHTML = strHTML & "<b> Campaign Reporting Web Id is activated.Now can subscribe/Download our reports</b></br><br>"
strHTML = strHTML & "Click here to goto the<a href=http://campaignreporting.verizon.com/campaign_reporting/login.html>Login page</a>"
strHTML = strHTML & "<br><h3>This is an automated message.Please do not reply</h3>"
strHTML = strHTML & "</BODY>"
strHTML = strHTML & "</HTML>"

With iMsg
Set .Configuration = iConf
.To =kk(i)
.From = "[email protected]"
.Subject = "Testing....pls ignore"
.HTMLBody = strHTML
.Send
End With
Next
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
Response.write "E-mails sent"


 
Old September 14th, 2004, 12:13 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi
Default

Dear you simply check that if the string of email is empty then dont send mail else send



Numan
--------------------------------------------------
Love is the most precious thing of this world. So find it and grab it!
 
Old September 14th, 2004, 05:52 PM
Authorized User
 
Join Date: Sep 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I did.but now its showing a new error.pls help.
Error Type:
CDO.Message.1 (0x8004020C)
At least one recipient is required, but none were found.
can u please post a sample code for sending e-mails to multiple users,by pulling data from database.Thanks!

 
Old September 15th, 2004, 02:14 PM
Authorized User
 
Join Date: Sep 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have corrected the problem with the help of a co-worker.The loop should end with -1.

For i=0 to Ubound(kk1) -1


thats it.Everythingis ok.

 
Old September 15th, 2004, 11:45 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Widad,

When you want to send it to multiple users, the email addresses should be separated by semi colon as shown below.

MyMail.To = "[email protected];[email protected]"

You may also do it this way, only if the list of recipients is not huge.
Code:
objRS.open strSql, objConn, adOpenStatic, adLockReadOnly 
arrMailIds = GetRows(objRS) ' Results an Array of email Ids.
objConn.Close
strMailIds = Join(arrMailIds, ";") ' Joins the Array into a string separated by SEMICOLON.
Set objConn = Nothing
Now strMailIds is ready to use in TO field, contains all the recipients.

Note: If the recipient list is too large, Please don't follow this methods. I recommend this only for recipient list of moderate length.

Hope that helps
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old September 16th, 2004, 10:42 AM
Authorized User
 
Join Date: Sep 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the suggestion.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Source: CDO.Message.1 please help me:) ilknur SQL Server 2000 1 July 23rd, 2006 12:52 PM
Need help related CDO.Message shankhan Classic ASP Basics 9 January 2nd, 2005 07:08 PM
Error 2295 Unknown message recipient(s) ron VB Databases Basics 0 November 7th, 2003 02:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.