For Windows 2000 / 2003 Server, CDOSYS is best for sending email from Active Server Pages. Because CDOSYS is installed on all of them by default.

Scenario 1: Sending email using a "local pickup directory".

You have the IIS SMTP Virtual Server Running. If you are on a local development machine. Under this scenario any emails you send from, your scripts put a ".eml" file in the local pickup directory. Then hopefully the SMTP Virtual Server grabs the file and sends it off. The Virtual SMTP server is however known to hiccup and not send out the emails right away.

Set up:

<%
Dim ObjSendMail
Dim iConf
Dim Flds
     
Set ObjSendMail = Server.CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
     
Flds("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
     
'**** Path below may need to be changed if it is not correct
Flds("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:\inetpub\mailroot\pickup"
Flds.Update
     
Set ObjSendMail.Configuration = iConf
ObjSendMail.To = "sendmail@sendmail.net"
ObjSendMail.Subject = "this is the subject"
ObjSendMail.From = "sendmail@sendmail.net"
     
' we are sending a text email.. simply switch the comments around to send an html email instead
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = "this is the body"
     
ObjSendMail.Send
     
Set ObjSendMail = Nothing
%>

Scenario 2: Port Forwarding

Include this meta type library code on the page

<%
Dim ObjSendMail 
Dim iConf 
Dim Flds
     
Set ObjSendMail = Server.CreateObject("CDO.Message") 
Set iConf = Server.CreateObject("CDO.Configuration")
     
Set Flds = iConf.Fields 
With Flds 
.Item(cdoSendUsingMethod) = 2
.Item(cdoSMTPServer) = "mail-fwd" 
.Item(cdoSMTPServerPort) = 25 
.Item(cdoSMTPconnectiontimeout) = 10 
.Update 
End With
     
Set ObjSendMail.Configuration = iConf
     
Set ObjSendMail.Configuration = iConf
ObjSendMail.To = "sendmail@sendmail.net"
ObjSendMail.Subject = "this is the subject"
ObjSendMail.From = "sendmail@sendmail.net"
     
' we are sending a text email.. simply switch the comments around to send an html email instead
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = "this is the body"
     
ObjSendMail.Send
     
Set ObjSendMail = Nothing 
Set iConf = Nothing 
Set Flds = Nothing
%> 

Scenario 3: Sending the email using a remote mail server.

This supports outgoing SMTP authentication. This method is also the best method to use because you are using a real email server with valid MX records. 

<%
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message") 
     
'This section provides the configuration information for the remote SMTP server.
     
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.sitename.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
     
' If your server requires outgoing authentication uncomment the lines bleow and use a valid email address and password.
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="sendmail@server.com"
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword"
     
ObjSendMail.Configuration.Fields.Update
     
'End remote SMTP server configuration section==
     
ObjSendMail.To = "sendmail@sendmail.net"
ObjSendMail.Subject = "this is the subject"
ObjSendMail.From = "sendmail@sendmail.net"
     
' we are sending a text email.. simply switch the comments around to send an html email instead
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = "this is the body"
     
ObjSendMail.Send
     
Set ObjSendMail = Nothing 
%>
You also add other options:

For more information: Check Microsoft's CDOSYS Documentation

Bu cavab sizə kömək etdi? 0 istifadəçi bunu faydalı hesab edir (0 səs)