Jump to content

Cdo Email Error


Lucas_Tiridath

Recommended Posts

Hi,I have just created a series of asp pages which are linked to a microsoft Access database. Having got this working, I have started trying to add automated emails to inform the end user of the changes which have been made. The code I am using has come straight off the w3schools website and is as follows:

sub SendEmail(sEmailTo, sSubject, sMessage, sEmailFrom)	' ---------- Send Email ----------	Set myMail=CreateObject("CDO.Message")	myMail.Subject=sSubject	myMail.From=sEmailFrom	myMail.To=sEmailTo	myMail.TextBody=sMessage	myMail.Send	set myMail=nothing	' --------------------end sub

This sub is then called whenever I need to send an email. However when I run this code, the following error occurs:CDO.Message.1 error '80040220'The "SendUsing" configuration value is invalid./webfrontend/finish.asp, line 109line 109 is:myMail.SendI am creating this website on my laptop. This runs windows 7 and has asp and iis enabled. As it says that CDO is a component of asp on the w3schools website, I assume that I have the components I need. I am running the website from the localhost.Any thoughts on what I have done wrong and how I can fix it would be greatly appreciated.Thanks in advance,Laurie

Link to comment
Share on other sites

Hi,Thanks for your response. However I'm afraid I still don't really understand what I need to do. I've tried several combination of the code suggested on links from your Google search but I have had no luck in getting it to work. I was wondering if you could explain what the other lines of code I need are and what they do because I'm struggling to work out what code does and what I need.I have also notices in a couple of places that lines such as what follows are suggested

<!-- 	METADATA 	TYPE="typelib" 	UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"  	NAME="CDO for Windows 2000 Library" -->

Firstly, what does this mean? Further when I use this, I start finding that me.request no longer works as it returns an error which says something like this object does not support the request attribute.Any help would be greatly appreciated.EDIT:OK I have tried using the following code which was recommended from a website I found:

sub SendEmail(sEmailTo, sSubject, sMessage, sEmailFrom)	' ---------- Send Email ----------	Set oCdoMail = Server.CreateObject("CDO.Message")	Set oCdoConf = Server.CreateObject("CDO.Configuration")					sConfURL = "http://schemas.microsoft.com/cdo/configuration/"	with oCdoConf		.Fields.Item(sConfURL & "sendusing") = 2		.Fields.Item(sConfURL & "smtpserver") = "localhost"		.Fields.Item(sConfURL & "smtpserverport") = 80		.Fields.Update	end with					with oCdoMail		.From = sEmailFrom		.To = sEmailTo	end with					with oCdoMail		.Subject = sSubject		.TextBody = sMessage	end with					oCdoMail.Configuration = oCdoConf	oCdoMail.Send	Set oCdoConf = Nothing	Set oCdoMail = Nothing	' --------------------end sub

Now when I run this, I receive the following error:CDO.Message.1 error '80040213'The transport failed to connect to the server./webfrontend/finish.asp, line 125Line 125 is: oCdoMail.SendNow I gather than this message is to do with having incorrectly entered the server details. However I am most definitely using the localhost on my computer as the server. Further, I have checked the port in my iis manager and I have seen that 80 is correct.Any thoughts on why this is occurring would be greatly appreciated.

Link to comment
Share on other sites

Email doesn't send using a web server on port 80. HTTP traffic uses a web server on port 80. SMTP traffic requires an SMTP server, usually on port 25. This:.Fields.Item(sConfURL & "smtpserver") = "localhost"Is asking for an SMTP server, not a web server. Mail servers and web servers aren't the same thing, mail servers don't serve HTTP requests and web servers don't send email.

I have also notices in a couple of places that lines such as what follows are suggestedCODE<!-- METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows 2000 Library" -->Firstly, what does this mean?
That doesn't look familiar, I haven't seen something like that before.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...