...

View Full Version : CDO "object required" error



shiftless
01-05-2008, 12:01 AM
Hi I am trying to use CDO for sending an email via a form and am getting an error message. This is my first time trying this and I am not a programmer. Here's my relevant code:


sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = Server.CreateObject("CDO.Configuration")
cdoConfig.Fields.Item(sch & "sendusing") = 2
cdoConfig.Fields.Item(sch & "smtpserver") = "127.0.0.1"
cdoConfig.fields.update


'Create and send your email here
mail = "officecatering@comcast.net"
reply = request.form("Email")
Set cdoMessage.Configuration = cdoConfig
cdoMessage.From = reply
cdoMessage.To = mail
cdoMessage.Subject = "Order from the Officecatering.net web site"
cdoMessage.TextBody = sBody

cdoMessage.Send
Set cdoMessage = Nothing
Set cdoConfig = Nothing

' Now send confirmation email to user
Set cdoMessage.Configuration = cdoConfig
cdoMessage.From = "donotreply@officecatering.net"
cdoMessage.Subject = "Your order from the Officecatering.net web site"
cdoMessage.To = reply
cdoMessage.TextBody = "This is a copy of your order from Officecatering.net:" & vbCrLf & _
"" & vbCrLf & _
sBody & _
"" & vbCrLf & _
"Thank You!"

cdoMessage.Send
Set cdoMessage = Nothing
Set cdoConfig = Nothing

I get this error:


Microsoft VBScript runtime error '800a01a8'

Object required: 'cdoMessage'

/cgi-bin/confirmation3.asp, line 64

Line 64 is this : Set cdoMessage.Configuration = cdoConfig

I tried adding this line near the top but it also gave me the same error message:

Set cdoMessage = Server.CreateObject("CDO.Message")


What am I doing wrong?

tonyyeb
01-05-2008, 11:38 AM
Take a look here for an example of how it is done:

http://www.lewisroberts.com/?p=64

shiftless
01-06-2008, 12:56 AM
here is the final code that actually works. Also, I did not include the top line of code that declares variables ie:

DIM cdoMessage, cdoConfig, etc., etc.

Not sure if that was necessary though...


the CDO code is this. I think the 2nd half was the problem, as I did not create the new objects for the 2nd email:


sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoMessage = Server.CreateObject("CDO.Message")
Set cdoConfig = Server.CreateObject("CDO.Configuration")
cdoConfig.Fields.Item(sch & "sendusing") = 2
cdoConfig.Fields.Item(sch & "smtpserver") = "127.0.0.1"
cdoConfig.fields.update


'Create and send your email here
mail = "email@email.net"
reply = request.form("Email")
Set cdoMessage.Configuration = cdoConfig
cdoMessage.From = reply
cdoMessage.To = mail
cdoMessage.Subject = "Order from the web site"
cdoMessage.TextBody = sBody

cdoMessage.Send
Set cdoMessage = Nothing
Set cdoConfig = Nothing

Set cdoMessage = Server.CreateObject("CDO.Message")
Set cdoConfig = Server.CreateObject("CDO.Configuration")
cdoConfig.Fields.Item(sch & "sendusing") = 2
cdoConfig.Fields.Item(sch & "smtpserver") = "127.0.0.1"
cdoConfig.fields.update

Set cdoMessage.Configuration = cdoConfig
cdoMessage.From = "donotreply@officecatering.net"
cdoMessage.Subject = "Your order from the abc.net web site"
cdoMessage.To = reply
cdoMessage.TextBody = "This is a copy of your order from Officecatering.net:" & vbCrLf & _
"" & vbCrLf & _
sBody & _
"" & vbCrLf & _
"Thank You!"

cdoMessage.Send
Set cdoMessage = Nothing
Set cdoConfig = Nothing



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum