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!

ASP 3.0 - CDONTS object - No Error, but not getting email

Status
Not open for further replies.

jetar

Programmer
Oct 16, 2003
49
US
Hey all,

I am using the CDONTS object to to send an email to myself to notify me whenever a form on my site is filled out. I am runninf windows xp pro and using IIS 5.1. When I initially tried to code the functionality, I was getting an error when I tried to create the CDONTS object so I then went and downloaded the cdonts.dll and registered it. The error went away and everything appeared to work except I am not receiving the emails and not getting any errors.

My question is, do I need to have something other than just IIS setup. Do I need to be hosting a mailserver or have one at my disposal. The addresses I am using in the .To and .From properties of the CDONTS object are hotmail addresses, not sure if it likes that idea. I list some of my code below. Thanks for the help.

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

objCDO.From = "name@aol.com"
objCDO.To = "name@hotmail.com"
objCDO.Subject = "Subject Text"
objCDO.BodyFormat = 1

strBody = "<html><head></head><body>"
strBody = strBody & "<table border='1' cellpadding='3' cellspacing='3' style='border-collapse: collapse' bordercolor='#111111' width='400' id='AutoNumber1'>"
strBody = strBody & "<tr><td width='77'>Name:</td><td width='320'>" & strName & "&nbsp;</td></tr>"
strBody = strBody & "<tr><td width='77'>Idea:</td><td width='320'>" & strIdea & "&nbsp;</td></tr>"
strBody = strBody & "<tr><td width='77'>Comment:</td><td width='320'>" & strComment & "&nbsp;</td></tr>"
strBody = strBody & "</table></body></html>"

objCDO.Body = strBody
objCDO.Send

 
try

if objCDO.Send = true then
response.write "Mail sent"
end if
 
If you're using windows XP, try using CDO instead of CDONTS, especially if you're likely to be migrating your site to 2003 server at any point in the future. E.g.
Code:
Set objNewMail = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
With Flds 
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2 ' cdoSendUsingPort
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = "smtp.mail.server"
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")[/URL] = 10 ' quick timeout
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/urlgetlatestversion")[/URL] = True
	.Update
End With

message = "HTML message text"
With objNewMail
	.From = "name@aol.com"
	.To = "name@hotmail.com"
	.Subject = "subject text"
	.HTMLBody = message
	.send	  'Send the new email
end with 		
set objNewMail = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top