homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

Can SMTP be specified?

10+ Year Member

Msg#: 1419 posted 9:44 am on Feb 5, 2004 (gmt 0)


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"





10+ Year Member

Msg#: 1419 posted 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.


10+ Year Member

Msg#: 1419 posted 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
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"
End With

'-- Destroy Objects --
Set objMessage = Nothing
Set objConfig = Nothing

It is a rewritten version of [developersdex.com ] which is an ASP.NET version.


Global Options:
 top home search open messages active posts  

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved