Welcome to WebmasterWorld Guest from 184.108.40.206 , register , free tools , login , search , subscribe , help , library , announcements , recent posts , open posts Subscribe and Support WebmasterWorld
CDONTS and SMTP Can SMTP be specified? webboy1 msg:942046 9:44 am on Feb 5, 2004 (gmt 0) Hi,
We have an ASP mail script running on our server, and all is fine with it.
However, we have been asked by our host to specify somewhere in the code which SMTP server the mail should be sent through.
I know this can be done with ASPmail and ASPemail. Can it be done with CDONTS?
Obviously, if i have to, i will just change the code, but hoped I might be able to add something to my CDONTS before re-writing to ASPemail.
The code i have used is like this:
Set mail = Server.CreateObject("CDONTS.NewMail") mail.From = "email@example.com" mail.To = "email pulled from Database" mail.Subject = "My email subject" mail.Body = "messaage goes here" mail.Send %>
TheNige msg:942047 8:44 pm on Feb 5, 2004 (gmt 0)
Not with classic ASP...have to use the IIS SMTP on that machine as far as I know. I believe that with ASP.Net you can use the built in mail namespaces that ride CDONTS to specify another server other than the default though. ebouwsema msg:942048 7:36 pm on Feb 6, 2004 (gmt 0)
If you are running on IIS5 (W2K) or newer you can specify mail using the improved CDOSYS object rather than the old CDONTS.
CDOSYS is similar to CDONTS but allows you to specify the CDO.Configuration object which allows you to send to another SMTP server.
Below is some example code:
'-- Dimension and Create Objects -- Dim objMessage, objConfig Set objMessage = Server.CreateObject("CDO.Message") Set objConfig = Server.CreateObject("CDO.Configuration") '-- Create Configuration -- With objConfig.Fields .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.example.com" .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10 .Update() End With '-- Send Email -- With objMessage .Configuration = objConfig .To = "firstname.lastname@example.org" .From = "email@example.com" .Subject = "Test Email" .HTMLBody = "Test Email Body" .Send() End With '-- Destroy Objects -- Set objMessage = Nothing Set objConfig = Nothing
It is a rewritten version of [
] which is an ASP.NET version. developersdex.com