473,849 Members | 1,797 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 3470
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
2321
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
3102
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 real email is hosted remotely, I checked with the admin and she said no changes were made, i.e., not...
9
1692
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
2771
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" objSendmail.To = "myaccount@home.com" objSendmail.Subject = "Subject Line"
5
1661
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
11200
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 time getting the new CDO mail to work properly. Any assistance with this would be greatly...
2
9392
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 ASP, the code was: objMail = Server.CreateObject("CDONTS.NewMail"); objMail.To =...
5
8798
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 = "Mail Example Subject";
4
2073
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 in the code for the first form.asp but what needs to be changed in the one that sends the email? Is...
0
9738
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10723
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9501
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7894
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7070
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5735
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5921
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4544
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
2
4139
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.