Wrox Programmer Forums
|
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 February 15th, 2005, 09:33 PM
Registered User
 
Join Date: Feb 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using CDO objects in ASP

I have currently upgraded from SBS 4.5 to SBS 2000. I have exchange server colocated on the IIS server. I was using, but have now switched to CDOSYS. I am completely stuck. I have attached my code for review:
        Dim iMsg
    Dim iConf
    Dim Flds
    Dim HTML

    Const cdoSendUsingPort = 2

    set iMsg = CreateObject("CDO.Message")
    Set iConf = CreateObject ("CDO.Configuration")
    Set Flds = iConf.Fields

    With Flds
 .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "cdaasvr.cdaa.local"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    .Update

    End With


    HTML = "This is a test"

    With iMsg
       Set .Configuration = iConf
       .To = "[email protected]"
       .From = "[email protected]"
        .Subject = "Testing"
        .HTMLBody = HTML
        .Send
     End With

     ' Clean up variables.
    Set iMsg = Nothing
    Set iConf = Nothing
    Set Flds = Nothing

When I execute this code the error reads:
Microsoft VBScript runtime (0x800A0411)
Name redefined: 'cdoSendUsingPort'

Any help would be appreciated. I have created a .VBS script that work fine, except for the Const cdoSendUsingPort = 1. I have tried that code also but receive the same error.

Thanks
Debbie
 
Old February 15th, 2005, 10:09 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Jonax
Default

I recently had to code for both CDONTS and CDOSYS - I came up with the following - hope it helps:

Code:
Sub SendMailCDOSYS(sFrom, sTo, sSubject, sBody, sAttachmentPath)
Dim sch, cdoConfig, MyMail
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
cdoConfig.Fields.Item(sch & "sendusing") = 2 'cdoSendUsingPort
cdoConfig.Fields.Item(sch & "smtpserver") = "smtp.tele2.dk"
cdoConfig.Fields.update
Set MyMail = Server.CreateObject("CDO.Message")
Set MyMail.Configuration = cdoConfig
MyMail.From = sFrom
MyMail.To = sTo
MyMail.Subject = sSubject
MyMail.HTMLBody = sBody
MyMail.AddAttachment sAttachmentPath
MyMail.Fields("urn:schemas:httpmail:importance").Value = 2
MyMail.Fields.Update()
MyMail.Send()
Set MyMail = Nothing
End sub

Sub SendMailCDONTS(sFrom, sTo, sSubject, sBody, sAttachmentPath)
    Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
    objCDOMail.From = sFrom
    objCDOMail.To = sTo
    objCDOMail.Subject = sSubject
    objCDOMail.Body = strBody
    objCDOMail.Importance = 2 '(0=Low, 1=Normal, 2=High)
    objCDOMail.BodyFormat = 0 ' CdoBodyFormatHTML
    objCDOMail.MailFormat = 0 ' CdoBodyFormatHTML
    If sAttachmentPath <> "" Then
            objCDOMail.AttachFile sAttachmentPath
    End If
    objCDOMail.Send
    Set objCDOMail = Nothing        
End Sub
 
Old February 15th, 2005, 10:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Jonax
Default

You'll want to change the SMTP-server...

 
Old February 16th, 2005, 12:07 AM
Registered User
 
Join Date: Feb 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Jonax --

Thanks for your suggestion, but I have tried every combination of the SMTP server I can think of. When using the .vbs file is works when you change the port number to 1, but putting it into ASP it does not.

Any other suggestons??


 
Old February 16th, 2005, 04:10 PM
Registered User
 
Join Date: Feb 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

HI All --

Thanks the suggestions. Apparently, the code above was working, but was giving me an error in the browser. Some people recieved up to about 15 e-mails.

I am not sure how it happened but all of my CDONTS code started working. The only suggestions I have for others upgrading from Windows NT 4.0 to Windows 2000 server is to register the DLL and wait about 2 days.

Thanks again
Debbie







Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with CDO and ASP nancy Classic ASP Professional 2 April 7th, 2006 08:13 AM
ASP CDO MAIL cullancrothers Classic ASP Professional 2 February 24th, 2006 06:16 PM
ASP CDO.Message difficulty crmpicco Classic ASP Basics 0 March 1st, 2005 07:48 AM





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