Relay All ASP Email to outside SMTP?

When I send email through an ASP page through my local "intranet" it sends through the normal IIS Default SMTP server.  Is there a way to make an external SMTP server the default.  In other words I want all email through ASP to be sent through  Is this possible?
Who is Participating?
What email component are you using?  Most of them allow you to specify what mail server to send through.  If you're using CDO, you can use this code:

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

Dim objConfig  ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields     ' As ADODB.Fields

' Get a handle on the config object and it's fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields

' Set config fields we care about
With Fields
      .Item(cdoSendUsingMethod)       = cdoSendUsingPort
      .Item(cdoSMTPServer)            = "smtp_server_name"
      .Item(cdoSMTPServerPort)        = 25
      .Item(cdoSMTPConnectionTimeout) = 10
      .Item(cdoSMTPAuthenticate)      = cdoBasic
      .Item(cdoSendUserName)          = "username"
      .Item(cdoSendPassword)          = "password"

End With

Set objMessage = Server.CreateObject("CDO.Message")

Set objMessage.Configuration = objConfig

With objMessage
      .To       = "Display Name <email_address>"
      .From     = "Display Name <email_address>"
      .Subject  = "SMTP Relay Test"
      .TextBody = "SMTP Relay Test Sent @ " & Now()
End With

Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing

Alternatively, you could configure your local SMTP server as a smarthost to another mail server.
Sam PanwarSr. Server AdministratorCommented:

This is possible through the ASP for it you can use the CDOSYS code CDOSYS support Window 2003 and forwindow 2000 server  CDONTS
/Use the following code in your asp page

Use following code for CDOSYS Email componets.
Set cdoConfig = Server.CreateObject("CDO.Configuration")
cdoConfig.Fields.Item(sch & "sendusing") = 2
cdoConfig.Fields.Item(sch & "smtpserver") = ""
Set cdoMessage = Server.CreateObject("CDO.Message")
Set cdoMessage.Configuration = cdoConfig
cdoMessage.From =
cdoMessage.To = "" = ""
cdoMessage.Subject = "enquiry form CDOSYS componets"
cdoMessage.HTMLBody = "your text"
Set cdoMessage = Nothing
Set cdoConfig = Nothing
response.redirect= ""

01. <%
02. Dim objCDOMail
03. Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
04. objCDOMail.From = ""
05. objCDOMail.To = ""
06. objCDOMail.Cc = ""
07. objCDOMail.Bcc = ""
08. objCDOMail.Subject = "Subject"
09. objCDOMail.BodyFormat = 0
10. objCDOMail.MailFormat = 0
11. objCDOMail.Body = "MailBody"
12. objCDOMail.Importance = 1
13. objCDOMail.Send
14. Set objCDOMail = Nothing
15. %>
Explanation According to Line
01. Open ASP tag
02. Declare a variable named objCDOMail
03. Create instance of Mailer control
04. Set Mailer control properties and collection items
05. Set Mailer control properties and collection items
06. Set Mailer control properties and collection items
07. Set Mailer control properties and collection items
08. Set Mailer control properties and collection items
09. Set Mailer control properties and collection items
10. Set Mailer control properties and collection items
11. Set Mailer control properties and collection items
12. Set Mailer control properties and collection items
13. Send Mail
14. Release resources
15. Close ASP tag

IF you get error then may be your server have not installed CDOSYS check and then try
there is an option of smart host in IIS SMTP server. there i think you can give your ISP`s SMTP server
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

gillwebAuthor Commented:
This SmartHost seems like the way to go since apparently the CDOSYS option isn't on my machine?  Can some one explain how I tell IIS to send mail through an ISP SMTP?
gillwebAuthor Commented:
gexen....i think your solution for CDO is working.  Is there a way to make this a FUNCTION to be able to import it into different pages easily?
gillwebAuthor Commented:
I keep getting IIS shutting down giving me an error stating this:

zAppName : inetinfo.exe     szAppVer : 5.1.2600.2180    
szModName : ntfsdrv.dll     szModVer : 6.0.2600.1     offset : 000032e3

Any ideas?
Sam PanwarSr. Server AdministratorCommented:

for your information cdosys is already installed on the window server 2003 if you have installed the .

This ntfs file error this may due to the permission of the IIS file in th ntfs
you have any changes in the IIS recently or permission

check the permission and event viewer for more erro discription
Sam PanwarSr. Server AdministratorCommented:
Also check the metabase setting of IIS
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.