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

Using CDONTS in windows xp pro? 1

Status
Not open for further replies.

MrPeds

Programmer
Jan 7, 2003
219
GB
Hi,

I would like to send email via my .asp page.

I am using Windows XP Pro and IIS 5.1.

I know that you can send email via asp pages in Windows NT but when I try the follwing code:

Set Obj = Server.CreateObject("CDONTS.NewMail") I get an error saying "ActiveX Component cannot create object".

Is there any way of sending simple email messages usign asp in xp pro? If so how?

Alternatively, can i do the same thing using a vbs file instead? I've tried using the same code in a .vbs file but get the same error :
Set Obj = CreateObject("CDONTS.NewMail") gets the same error.

Thanks

MrPeds
 
Set Obj = Server.CreateObject("CDONTS.NewMail")

That is the correct syntax. However, if you don't have the SMTP service installed, it won't work.
 
CDONTS is not included with Windows XP. This object was included with windows 2000 only to allow applications from Windows NT to be compatible. I believe Spazman is correct in that CDOSYS is the new object (or perhaps just CDO?) that is installed with Windows XP. Other optiojns would include using third party objects such as ASPEmail, JMail, etc.

-Tarwn ________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
CDONTS (CDONTS.dll) was introduced on and intended only for WinNT Server. Tarwn, is right, it was on Win2K for backwards compatibility. It uses SMTP.

CDO 1.2 (CDO.dll) was introduced for the client side and connects using MAPI (i.e. Exchange). Introduced for Win2K.

CDO For Windows 2000 (CDOSYS.dll) is the latest and uses SMTP and NNTP to send MIME formatted emails.

MS does a good job of confusing the issue.

Chris.
 
I forgot to mention the sytax for the message object each one:

CDONTS is Set Obj = Server.CreateObject("CDONTS.NewMail")

CDO 1.2 is Set Obj = Server.CreateObject("MAPI.Message")

CDO for Window 2000 is Set Obj = Server.CreateObject("CDO.Message")


Chris.
 
Good post chris, I find I am falling behind a little bit as I refuse to give up any of my Windows 2000 boxes to install XP :)
Thanks for the information, hope everyone else finds it useful as well.
-Tarwn ________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
Thanks for this guys,

I will post my solution when completed as it may be useful to others,

MrPeds
 
hello everyone!!!i have the same problem with my email page..

i have tried eveything but it just doesnt seem to work.

could some pls tell me the lines of code for creatins the object for mail..

i am currnently using the lines

Code:
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
objCDOMail.From = Request.Form(&quot;firstName&quot;) & &quot; &quot; & Request.Form(&quot;lastName&quot;) & &quot; <&quot; & strReturnEmailAddress & &quot;>&quot;
objCDOMail.To = strMyEmailAddress
objCDOMail.Cc = strCCEmailAddress
objCDOMail.Bcc = strBCCEmailAddress
objCDOMail.Subject = &quot;Enquiry sent from enquiry form on website&quot;
objCDOMail.BodyFormat = 0
objCDOMail.MailFormat = 0
objCDOMail.Body = strBody
objCDOMail.Importance = 2 
objCDOMail.Send
Set objCDOMail = Nothing

but it gives me an error sayin that &quot;error creating object&quot;

or else if some noe could tell me how i could just go to outlook fron the page after selecting the email id'd to where i wish to send the mails...without using the hreff..

cause i need to import the email id's from the sql server and then be able to out them in the cc text box and send the mail..implyin he sql server is my address bool..

thanks in advance cuase i know i can count u guyss

sameer
 
What version of windows are you using? ________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
Ok, the solution was posted above in this same thread, it should help you out in your situation.
-Tarwn ________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
Hi,

The following works on XP Pro, using VBScript / ASP:

'create email object
Set em = CreateObject(&quot;CDO.Message&quot;)

em.To = &quot;sombody@someDestinationAddress.com&quot;
em.From = &quot;somebody@somewhere.com&quot;
em.Subject = &quot;The Subject&quot;
em.Body = &quot;some message&quot;

em.Send

If you want to use CDONTS you need to download cdonts.dll, place the .dll into windows/system32 and register the dll using regsvr32 cdonts.dll.

Then the CDONTS code should work above.

MrPeds
 
Hello, everyone.

I also have same problem with using CDONTS. I have CDONTS installed winnt\system32 folder. I also have SMTP server installed. But I still get the same error message.

So, I want to try CDO object but I don't have it.

Where can I download it?

Thanks..
 
shouldn't first line be:

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

NOT

Set objCDOMail = Server.CreateObject("CDONTS.NewMail")


if xp CDONT obj won't work unless you went through the hassle of installing the .dll...but why when cdo is the way to go?

 
bsl is correct -

it should be
Code:
Set em = CreateObject("CDONTS.NewMail")

em.To = "sombody@someDestinationAddress.com"
em.From = "somebody@somewhere.com"
em.Subject = "The Subject"
em.Body = "some message"

em.Send
set em=nothing
response.write "message sent"

if you have win xp cdo.sys should already be installed

Code:
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.TextBody="This is a message."
myMail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")=2[/URL]
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] _
="smtp.server.com"
'Server port
myMail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] _
=25 
myMail.Configuration.Fields.Update
myMail.Send
%>
 
sorry just clarifying

Code:
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.TextBody="This is a message."

[red]
myMail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")=2[/URL]
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] _
="smtp.server.com"
'Server port
myMail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] _
=25
myMail.Configuration.Fields.Update
[/red]

myMail.Send
%>

areas in red may not be needed depending on server config

also ther are other methods of sending with cdo.sys like

Code:
myMail.HtmlBody="<strong>This is a message.</strong>"

Code:
myMail.CreateMHTMLBody "[URL unfurl="true"]http://www.yourdomain.com/yourhtmlpage.asp",31[/URL]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top