473,574 Members | 2,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.CreateOb ject("CDONTS.Ne wMail")
Mail.To = "XX**********@X XXXXX.COM"
Mail.From = "YY*******@YYYY Y.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 3452
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.CreateOb ject("CDONTS.Ne wMail")
Mail.To = "XX**********@X XXXXX.COM"
Mail.From = "YY*******@YYYY Y.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*******@gmai l.comwrote in message
news:fd******** *************** ***********@w8g 2000prd.googleg roups.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.CreateOb ject("CDONTS.Ne wMail")
Mail.To = "XX**********@X XXXXX.COM"
Mail.From = "YY*******@YYYY Y.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 cdoSendUsingMet hod =
"http://schemas.microso ft.com/cdo/configuration/sendusing"
Const cdoSMTPServer =
"http://schemas.microso ft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPi ckupDirectory =
"http://schemas.microso ft.com/cdo/configuration/smtpserverpicku pdirectory"
Const cdoSMTPServerPo rt =
"http://schemas.microso ft.com/cdo/configuration/smtpserverport"

Const cdoSendUsingPic kup = 1
Const cdoSendUsingPor t = 2

Dim oMsg : Set oMsg = CreateObject("C DO.Message")
Dim oConfig : Set oConfig = CreateObject("C DO.Configuratio n")

With oConfig.Fields
.Item(cdoSendUs ingMethod) = cdoSendUsingPor t
.Item(cdoSMTPSe rver) = "mysmtp.myserve r.com"
.Item(cdoSMTPSe rverPort) = 25
.Update
End With

oMsg.From = "Me <me@mymail.myse rver.com>"
oMsg.To = "Bloke <bl***@somewere .com>"
oMsg.Subject = "Test"
oMsg.HTMLBody = "<html><body>He llo World</body></html>"
Set oMsg.Configurat ion = oConfig
oMsg.Send

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

news:fd******** *************** ***********@w8g 2000prd.googleg roups.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.CreateOb ject("CDONTS.Ne wMail")
Mail.To = "XXXXXXXXX...@X XXXXX.COM"
Mail.From = "YYYYYY...@YYYY Y.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 cdoSendUsingMet hod =
"http://schemas.microso ft.com/cdo/configuration/sendusing"
Const cdoSMTPServer =
"http://schemas.microso ft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPi ckupDirectory =
"http://schemas.microso ft.com/cdo/configuration/smtpserverpicku pdirectory"
Const cdoSMTPServerPo rt =
"http://schemas.microso ft.com/cdo/configuration/smtpserverport"

Const cdoSendUsingPic kup = 1
Const cdoSendUsingPor t = 2

Dim oMsg : Set oMsg = CreateObject("C DO.Message")
Dim oConfig : Set oConfig = CreateObject("C DO.Configuratio n")

With oConfig.Fields
.Item(cdoSendUs ingMethod) = cdoSendUsingPor t
.Item(cdoSMTPSe rver) = "mysmtp.myserve r.com"
.Item(cdoSMTPSe rverPort) = 25
.Update
End With

oMsg.From = "Me <m...@mymail.my server.com>"
oMsg.To = "Bloke <bl...@somewere .com>"
oMsg.Subject = "Test"
oMsg.HTMLBody = "<html><body>He llo World</body></html>"
Set oMsg.Configurat ion = 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
2304
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 working with it for a few days (and nights), it finally came to my attention that it will only send 'To, From, Subject, Body' information and not
4
3086
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. If there haven't been any changes made to previously working code, where do I look for the problem now? I restarted the SMTPservice in IIS. Our...
9
1680
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 add a reply to piece to this, so when a user clicks on Reply, it sends it to a valid e-mail address. Thank you
5
2754
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 Pro and when running this simple code: ------------ Set objSendmail = Server.CreateObject("CDONTS.NewMail") objSendmail.From = "test@test.com"...
5
1641
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 the right direction. ?
6
11169
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 will include the code I originally used. I understand I should switch from CDONTS to CDO mail but after several sttempts I am finding a very hard...
2
9372
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 on how to do this using CDO. Unfortunately, I don't have that option. I must use C# and CDonts. Do you have any ideas or code? In traditional...
5
8785
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 with this code: MailMessage msgMail = new MailMessage(); msgMail.To = "test@address.com"; msgMail.From = "from@address.com"; msgMail.Subject =...
4
2058
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 form and creates a form.asp to mail and the one that takes that file and mails it, mail.asp. I believe I can figure out what needs to be altered...
0
7813
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7736
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7826
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8106
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5631
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5305
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3743
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2251
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1350
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.