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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using CDO object to mail from an asp page

Status
Not open for further replies.

zonash001

Programmer
Mar 10, 2004
15
PK
hi all...

i need some assistance on CDO Object....I m designing a suggestion box to be placed on company's intranet. And in relation, i've two questions related to sending
mails from an asp page.

The first one is how can i send anonymous emails from an asp page.

The second one is currently i m running Win XP, so to send mails from asp page i need to use CDO Object, and here
comes the problem. While trying to load the page in browser, it displays the following error message:

Technical Information (for support personnel)

Error Type:
(0x80040211)
/new/mailsugg.asp, line 36

Any suggestions on how to come up with a solution for these problems?
[Plz don't suggest to use CDONTS instead of CDO object...i need to get it done using CDO object]

Here is the code that i m trying out......

<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows 2000 Library" -->
<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->
<%
'Declare local variables to hold the data from the Input form page "suggbox".
Dim strFrom 'String for sender
Dim strBody 'String for body
Dim objMail 'The CDO object

'Read in the values passed from previous page
strFrom = Request.Form("From")
strBody = Request.Form("SuggBody")

' Create an instance of the NewMail object.
Set ObjMail = Server.CreateObject("CDO.Message")
Set objConfig = CreateObject("CDO.Configuration")

'Configuration:
objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort
objConfig.Fields(cdoSMTPServer) = "localhost"
objConfig.Fields(cdoSMTPServerPort) = 25
objConfig.Fields(cdoSMTPAuthenticate) = cdoBasic

'Update configuration
objConfig.Fields.Update
Set objMail.Configuration = objConfig

' Set the properties of the object
objMail.From = StrFrom
objMail.To = "myemail@mydomain.com"
objMail.Subject = "Online Suggestion Box - " + strFrom
objMail.HTMLBody = strBody

'objCDOMail.Importance = 1 '(0=Low, 1=Normal, 2=High)

' Send the message!
objMail.Send

' Set the object to nothing because it immediately becomes
' invalid after calling the Send method + it clears it out of the Server's Memory.
Set objMail = Nothing
Set objConfig = Nothing
%>
 
Well line 36 is your send command so the question is do you have you are configured correctly. We'll assume CDO is set up since you aren't getting and error when you establish the object.

I'm going to change your syntax a bit. Hopefully it will help.

Code:
<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows 2000 Library" -->
<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->
<%
'Declare local variables to hold the data from the Input form page "suggbox".
Dim strFrom    'String for sender
Dim strBody    'String for body
Dim objMail     'The CDO object
Dim objConfig	'the config object
Dim flds		'the configuration fields

'Read in the values passed from previous page
strFrom = Request.Form("From") 
strBody = Request.Form("SuggBody")

' Create an instance of the NewMail object.
 Set ObjMail = Server.CreateObject("CDO.Message") 
 Set objConfig = CreateObject("CDO.Configuration") 
 set flds = objConfig.Fields 
 
 'Configuration: 
 
 With flds
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = cdoSendUsingPort
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = "localhost"
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")[/URL] = 10
	.Update
 end with
 
 
 'Update configuration 
 
 Set objMail.Configuration = objConfig 

' Set the properties of the object

with objMail
	.Configuration = objConfig
	.From = StrFrom
	.To = "myemail@mydomain.com"
	.Subject = "Online Suggestion Box - " & strFrom
	.HTMLBody = strBody
end with     

'objCDOMail.Importance = 1 '(0=Low, 1=Normal, 2=High) 

' Send the message!
objMail.Send

' Set the object to nothing because it immediately becomes
' invalid after calling the Send method + it clears it out of the Server's Memory.
Set objMail = Nothing  
Set objConfig = Nothing  
set flds = nothing 
%>

The biggest difference is the config fields. I got the ones above from Microsoft and they seem to work ok for me (Win 2k server and 2k3 server).

Also now that I have another look at it you did not declare your objConfig variable. Try that first! That might be the only reason it isn't working for you.

Hope it helps!

Wow JT that almost looked like you knew what you were doing!
 
pixl8r's code worked to the extent that the error has been removed. The problem now is mails aren't received by the recepients. Instead they are queued at C:\Inetpub\mailroot\Queue

Wht to do now????????
 
Sorry to Intrude in between you, just wanted to know will it be possible to access the Global Access List or Address Book of Exchange Server from ASP? And what need to be installed on the Server to use CDO?

Help would be appreciated.

Regards,
Vikram
 
Try using valid e-mail addresses first. If that doesn't work you will need to make sure your SMTP server is correctly configured to allow sending. Unfortunately I am not the best guide for you on that.

I'm sure you can find more about that part of it in this forum.

Vik:

CDO is supported on windows 2000 server and above. I do not think that it has to be installed seperately. I'm not 100% on that though. Maybe someone else can comment.

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top