Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDOSYS Problems

Status
Not open for further replies.

hdog

Technical User
Mar 24, 2002
26
US
I have written some code to send an email from the server using CDOSYS. When I put a static email address in for the myMail.To= command it works fine but if I try to address a string from a variable (built from a recordset) I only get error '8004020f'. I have tried all I can think of but can't seem to get it to work. I have used Response.Write to write the string to the screen and all looks fine. Can anyone look at my code and help out???? Here's the code...

<% 'build email string for cdosys object below
While ((Repeat1__numRows_a <> 0) AND (NOT expired_members_a.EOF))%>
<span class="report_fields">
<% email_list_a=(expired_members_a.Fields.Item("UserEmail").Value)%>
<% email_list=email_list_a & ";" & email_list
Repeat1__index_a=Repeat1__index_a+1
Repeat1__numRows_a=Repeat1__numRows_a-1
expired_members_a.MoveNext()
Wend
%>
<%'format email string to include quotes
dim qt,address
qt = Chr(34)
address=cStr(qt&email_list&qt)
%>

<% 'send message using cdosys
Set myMail=Server.CreateObject("CDO.Message")
myMail.Subject="my subject!"
myMail.From="from address placed here"
myMail.To=address '***here is where my problem seems to be**
myMail.TextBody="This is a test message"
myMail.Configuration.Fields.Item _
("=2
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
(" _
="myservername"
'Server port
myMail.Configuration.Fields.Item _
(" _
=25
myMail.Configuration.Fields.Item _
(" _
= 1
myMail.Configuration.Fields.Item _
(" _
= "sendingusername"
myMail.Configuration.Fields.Item _
(" _
= "sendingpassword"
myMail.Configuration.Fields.Update
myMail.Send
set myMail=nothing
%>

Any help would be appreciated.

Thanks
 
forgot to add

CDOSYS has a limit on the number of addresses you can send to in one call, also everyone you send to using that setup will be able to see all the other recipients.


Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
I looked over the link you sent and still can't figure out what is going on. I added some code to give a better description on the error and now get the following info:

Microsoft VBScript runtime error '800a01a8'

Object required: 'myMail'

It looks to me like my variable 'address' is not formatted correctly and therefore the object is not getting defined correctly. But I can't figure out what I have wrong. When I do a Response.Write(address) all looks fine. Any ideas?
 
ok you added some more code (which we can't see) and get a different error.
My guess is there is something wrong with the extra code.

we can't see what the concatenated mail address looks like so have no idea whether there is an error or not.

fraid I'm out of guesses.



Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top