Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question CDO "object required" error

    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:

    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?

  • #2
    New Coder
    Join Date
    Dec 2007
    Location
    UK
    Posts
    41
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Take a look here for an example of how it is done:

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

  • #3
    New Coder
    Join Date
    Jan 2007
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    solution

    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:

    Code:
    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
    Last edited by shiftless; 01-06-2008 at 01:58 AM. Reason: typos


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •