473,405 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

A beginner question: Send Mail in ASP using CDONTS

Hi all,

I had to write a page in ASP which sends an email. I googled and was
able to write the following code:

<html>
<body>
<%
Set Mail = Server.CreateObject("CDONTS.NewMail")
Mail.To = "XX**********@XXXXXX.COM"
Mail.From = "YY*******@YYYYY.COM"
Mail.Subject = "Test MAIL Subject"
Mail.Body = " Body Body Body Body Body Bodyody Body Body"
If Mail.Send Then
Response.Write("Mail has been sent successfully")
Else
Response.Write("Mail Sending Failed")
End If
Set Mail = nothing
%>
</body>
</html>

When I run this script on a shared hosting server, It's saying "Mail
Sending Failed". I had never written ASP code before and couldn't find
what the reason is.. I also checked whether CDONTS.NewMail component
is available.

Please help me out..

Thanks in advance,
Prasad.

Jun 27 '08 #1
3 3434
Your host may not allow CDONTS. Microsoft stopped shipping CDONTS as a
standard part of the Windows Server a few years back. You host *CAN* add it,
but may have chosen not to.

It's possible that your host supports only CDOSYS, for example. And it's
even possible that you host doesn't support *any* MS email component and uses
one from a third party.

You should contact your host for the proper component to use. Hopefully,
your how will have a sample page in their FAQs.

If you can't get help from your host, then it might be time to change hosts.

"Prasad" wrote:
Hi all,

I had to write a page in ASP which sends an email. I googled and was
able to write the following code:

<html>
<body>
<%
Set Mail = Server.CreateObject("CDONTS.NewMail")
Mail.To = "XX**********@XXXXXX.COM"
Mail.From = "YY*******@YYYYY.COM"
Mail.Subject = "Test MAIL Subject"
Mail.Body = " Body Body Body Body Body Bodyody Body Body"
If Mail.Send Then
Response.Write("Mail has been sent successfully")
Else
Response.Write("Mail Sending Failed")
End If
Set Mail = nothing
%>
</body>
</html>

When I run this script on a shared hosting server, It's saying "Mail
Sending Failed". I had never written ASP code before and couldn't find
what the reason is.. I also checked whether CDONTS.NewMail component
is available.

Please help me out..

Thanks in advance,
Prasad.

Jun 27 '08 #2

"Prasad" <pr*******@gmail.comwrote in message
news:fd**********************************@w8g2000p rd.googlegroups.com...
Hi all,

I had to write a page in ASP which sends an email. I googled and was
able to write the following code:

<html>
<body>
<%
Set Mail = Server.CreateObject("CDONTS.NewMail")
Mail.To = "XX**********@XXXXXX.COM"
Mail.From = "YY*******@YYYYY.COM"
Mail.Subject = "Test MAIL Subject"
Mail.Body = " Body Body Body Body Body Bodyody Body Body"
If Mail.Send Then
Response.Write("Mail has been sent successfully")
Else
Response.Write("Mail Sending Failed")
End If
Set Mail = nothing
%>
</body>
</html>

When I run this script on a shared hosting server, It's saying "Mail
Sending Failed". I had never written ASP code before and couldn't find
what the reason is.. I also checked whether CDONTS.NewMail component
is available.
Here is some example code to send email using CDOSYS:-

Const cdoSendUsingMethod =
"http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSMTPServer =
"http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPickupDirectory =
"http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory"
Const cdoSMTPServerPort =
"http://schemas.microsoft.com/cdo/configuration/smtpserverport"

Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2

Dim oMsg : Set oMsg = CreateObject("CDO.Message")
Dim oConfig : Set oConfig = CreateObject("CDO.Configuration")

With oConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "mysmtp.myserver.com"
.Item(cdoSMTPServerPort) = 25
.Update
End With

oMsg.From = "Me <me@mymail.myserver.com>"
oMsg.To = "Bloke <bl***@somewere.com>"
oMsg.Subject = "Test"
oMsg.HTMLBody = "<html><body>Hello World</body></html>"
Set oMsg.Configuration = oConfig
oMsg.Send

--
Anthony Jones - MVP ASP/ASP.NET
Jun 27 '08 #3
On May 28, 11:06 pm, "Anthony Jones" <A...@yadayadayada.comwrote:
"Prasad" <prasad...@gmail.comwrote in message

news:fd**********************************@w8g2000p rd.googlegroups.com...
Hi all,
I had to write a page in ASP which sends an email. I googled and was
able to write the following code:
<html>
<body>
<%
Set Mail = Server.CreateObject("CDONTS.NewMail")
Mail.To = "XXXXXXXXX...@XXXXXX.COM"
Mail.From = "YYYYYY...@YYYYY.COM"
Mail.Subject = "Test MAIL Subject"
Mail.Body = " Body Body Body Body Body Bodyody Body Body"
If Mail.Send Then
Response.Write("Mail has been sent successfully")
Else
Response.Write("Mail Sending Failed")
End If
Set Mail = nothing
%>
</body>
</html>
When I run this script on a shared hosting server, It's saying "Mail
Sending Failed". I had never written ASP code before and couldn't find
what the reason is.. I also checked whether CDONTS.NewMail component
is available.

Here is some example code to send email using CDOSYS:-

Const cdoSendUsingMethod =
"http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSMTPServer =
"http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPickupDirectory =
"http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory"
Const cdoSMTPServerPort =
"http://schemas.microsoft.com/cdo/configuration/smtpserverport"

Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2

Dim oMsg : Set oMsg = CreateObject("CDO.Message")
Dim oConfig : Set oConfig = CreateObject("CDO.Configuration")

With oConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "mysmtp.myserver.com"
.Item(cdoSMTPServerPort) = 25
.Update
End With

oMsg.From = "Me <m...@mymail.myserver.com>"
oMsg.To = "Bloke <bl...@somewere.com>"
oMsg.Subject = "Test"
oMsg.HTMLBody = "<html><body>Hello World</body></html>"
Set oMsg.Configuration = oConfig

oMsg.Send

--
Anthony Jones - MVP ASP/ASP.NET

Hi..
Thank you all for your replies.. I git it worked. The actual problem
was with the "From Address", which should be of the same domain I have
taken. :)

Cheers,
Prasad
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Andrew Williams | last post by:
Hi, I have just created a web form that should send its details to an e-mail address. The problem is that I was working on the pretense that CDONTS would suffice my needs. However, after...
4
by: Tom Petersen | last post by:
Ok, I'm 99.9999999999999999999% sure there haven't been any code changes, since the date stamps of the code are older than any email 'failures' The email piece quit working using the mail.send. ...
9
by: dthmtlgod | last post by:
I am having an e-mail being sent from a form submitting on a web page. Right now, it is just a generic name (not a valid e-mail address) in the Mail From box. "Web Server Request". How can I...
5
by: Stuart Palmer | last post by:
I have had for sometime a problem getting cdo.message to work, so I have given up on this and tried to test a form on my localhost machine using CDONTS again (this used to work) I have win 2000...
5
by: RICHARD BROMBERG | last post by:
I am already using ASP/Cdonts to send the contents of a Form by e-mail and would like to include a link on my page to send the page itself by e-mail to a named recipient. Can anyone start me in...
6
by: DigitalRick | last post by:
I have been running CDONTS in my ASPpages to send emails to me sent from my guestbook. It had been working fine untill I upgraded to Server 2003 (I am also running Exchange 2003) all locally. I...
2
by: microsoft.public.dotnet.languages.csharp | last post by:
ASP.Net, C#, Email message, CDonts not CDO I am writing an ASP.Net application where I cannot use CDO. I must use CDonts. I cannot find an example of this on the Internet. I only see examples...
5
by: Andreas | last post by:
I am working with three computers, my developing computer, a Web Server and a Mail Server (Exchange). I am trying to send a email from the Web Server via the Mail Server to a valid email address...
4
by: Dr. Harvey Waxman | last post by:
I guess I should change from cdonts to cdosys. Since I am ignorant about asp I hope you forgive this basic question. There are two asp files for handling mail, the one that gets the info from a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.