472,139 Members | 1,636 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,139 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 3362
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Tom Petersen | last post: by
9 posts views Thread by dthmtlgod | last post: by
5 posts views Thread by RICHARD BROMBERG | last post: by
2 posts views Thread by microsoft.public.dotnet.languages.csharp | last post: by
5 posts views Thread by Andreas | last post: by
4 posts views Thread by Dr. Harvey Waxman | last post: by
reply views Thread by leo001 | last post: by

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.