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!

cdonts mail script errors

Status
Not open for further replies.

holidayIT

IS-IT--Management
Apr 2, 2004
138
US
I had a script that send an email using cdonts. I hed to register cdonts on the win2k3 box that the script runs on, and now one script works fine, the other doesnt. First, i had to setup a virtual smtp server in iis6 because Mdaemon (our new mail server) doesn't support cdonts messages (for whatever reason). So i reconfigured the script to use the virtual smtp, and now on one script i get an error in the .send line of "invalid address" for recipient. Why does the virtual smtp care? shouldn't it just send out the email regardless, and then have it fail on the actual mail server??? the addresses are passed to a "mailer" function as a variable argument. Does that matter? does anyone have any idea what could be causing this? or how i can trap the error in .send??? i tried if err.number <>0 then err.clear, but that didn't catch it.
 
CDONTS doesn't work on newer versions of IIS. Need to use CDO. Here is the code:

'Process email notification

Set m_objCDO = Server.Createobject("CDO.Message")
Set m_objCDOcon = Server.Createobject("CDO.Configuration")

Const cdoSendUsingMethod = "Const cdoSendUsingPort = 2
Const cdoSMTPServer = "Const cdoSMTPServerPort ="Const cdoSMTPConnectionTimeout = "Const cdoSMTPAuthenticate = "Const cdoBasic = 1
Const cdoSendUserName = "Const cdoSendPassword = "

'Sending email notification
set Fields = m_objCDOcon.Fields

'Setting up Message parameters
with Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
'Replace with your SMTP server
.Item(cdoSMTPServer) = "smtp.Server.com"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
'Only used if SMTP server requires Authentication
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "Username"
.Item(cdoSendPassword) = "Password"
.Update
end with

'Passing parameters to message object
Set m_objCDO.Configuration = m_objCDOcon

With m_objCDO
'Replace with email you wish the message to be sent to
.To = "email@youraddress.com"
'Replace with email you wish the message to be from
.From = "email@youraddress.com"
'Replace with subject
.Subject = "ASP Generated Email"
'Replace with information you want to be sent
.HTMLBody = "Place body here"
.Send
End With

Hope this helps

Cassidy
 
You have to correctly setup the SMTP server.
- relay
- connection
- SECURITY: add the ASPNET user to the operators list

Bogdan Bucura
CEO Widesoft SRL
Your software company
 
You can see the trap the error by seeing if there is a problem when you create a new CDONTS object.


--Create the object
if @result <> 0, there is an error.
PRINT 'Creating the CDONTS.NewMail object'
EXEC @result = sp_OACreate 'CDONTS.NewMail', @object OUTPUT

IF @result <> 0
BEGIN
PRINT 'sp_OACreate Failed'
RETURN @result
END

You can use CDONTS on W2K, but not on XP Home / Pro unless you install it from a W2K CD. Hope this helps.



 
i got it all working. sorry i didnt post back before. cdonts does work on iis 6, but microsoft does not support it. you have to register the dll, and it will work fine. the virtual smtp setup is a little more creative when using MDaemon for your mail server, as MDaemon does not accept cdonts with certain security settings turned on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top