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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDONTS mailing

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
I have a script below which will send an email upon submiting. I want my to field to come from a database. Here is what I have right now objCDO.To = rs.field("supervisorsemail").value. I get the following error message.

Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'rs.field'
/am1st/MyStuff/time.asp, line 76


Can you help?


if Request.Form("FFSubmitted") = "yes" then
FormFields = ""
If FormFields <> &quot;&quot; Then
arrFormFields = split(FormFields,&quot;~&quot;)
End If
Set objCDO = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
objCDO.From = &quot;timesheet@am1st.com&quot;
objCDO.To = rs.field(&quot;supervisorsemail&quot;).value
objCDO.Cc = &quot;&quot;
objCDO.Bcc = &quot;&quot;
objCDO.Subject = &quot;Please Approve this time&quot;
BodyString = Replace(&quot;&quot;,&quot;~&quot;,chr(13) & chr(10) )& chr(13)
If FormFields <> &quot;&quot; Then
For Each item In arrFormFields
BodyString = BodyString & item & &quot;: &quot; & Request.Form(item) & chr(13)
Next
End If
objCDO.Body = BodyString
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send
Set objCDO = Nothing
RedirectURL = &quot;&quot;
If RedirectURL <> &quot;&quot; then
If Request.QueryString <> &quot;&quot; Then
response.redirect(RedirectURL & &quot;?&quot; & Request.QueryString)
else
response.redirect(RedirectURL)
end If
end if
end if
%>
 
Hi

You should just need to specify your field differently:

Code:
objCDO.To = rs(&quot;supervisorsemail&quot;)

You seem to be confusing the ultradev way of writing fields with the asp programmer's way. Derren
[Mediocre talent - spread really thin]
 
the name of the property is &quot;fields&quot;, and it will work either way.

rs(&quot;fieldName&quot;)

or

rs.fields(&quot;fieldName&quot;)

Actually, the second way is faster since the recordset object doesn't have to figure out what it's default property is, but I admit that I don't do it that way just for the sake of speed of coding. The performance gain will be negligible.

:)
paul
penny1.gif
penny1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top