Welcome to WebmasterWorld Guest from 126.96.36.199
Forum Moderators: ocean10000
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"
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 --
.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
'-- Send Email --
.Configuration = objConfig
.To = "firstname.lastname@example.org"
.From = "email@example.com"
.Subject = "Test Email"
.HTMLBody = "Test Email Body"
'-- Destroy Objects --
Set objMessage = Nothing
Set objConfig = Nothing
It is a rewritten version of [developersdex.com ] which is an ASP.NET version.