Welcome to WebmasterWorld Guest from 54.196.232.162

Forum Moderators: ocean10000

Message Too Old, No Replies

CDONTS and SMTP

Can SMTP be specified?

     
9:44 am on Feb 5, 2004 (gmt 0)

Full Member

10+ Year Member

joined:Mar 15, 2002
posts:346
votes: 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 = "info@mydomain.com"
mail.To = "email pulled from Database"
mail.Subject = "My email subject"
mail.Body = "messaage goes here"

mail.Send
%>

cheers
Webboy

8:44 pm on Feb 5, 2004 (gmt 0)

Preferred Member

10+ Year Member

joined:Sept 30, 2003
posts:374
votes: 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.
7:36 pm on Feb 6, 2004 (gmt 0)

New User

10+ Year Member

joined:Feb 3, 2004
posts:14
votes: 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 = "user_receive@example.com"
.From = "user_send@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 [developersdex.com ] which is an ASP.NET version.

Eric