Difference between revisions of "Email in Scripts"
From Hostek.com Wiki
(→ASP Email Sample) |
|||
| Line 5: | Line 5: | ||
__FORCETOC__ | __FORCETOC__ | ||
==ASP Email Sample== | ==ASP Email Sample== | ||
| + | Here is a sample using CDOSYS to send email from ASP pages. CDOSYS replaces CDONTS on Windows 2003 servers and after. | ||
| + | |||
| + | NOTE: We suggest using CDOSYS for all ASP email applications. | ||
| + | |||
| + | <pre> | ||
| + | <% | ||
| + | Dim objCDOConf | ||
| + | Set objCDOConf = Server.CreateObject ("CDO.Configuration") | ||
| + | |||
| + | ' ** SET AND UPDATE FIELDS PROPERTIES ** | ||
| + | With objCDOConf | ||
| + | ' ** OUT GOING SMTP SERVER ** | ||
| + | |||
| + | ' ** SMTP PORT ** | ||
| + | .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpmailer.hostek.net" | ||
| + | |||
| + | ' ** CDO PORT ** | ||
| + | .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 | ||
| + | |||
| + | ' ** TIMEOUT ** | ||
| + | .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 | ||
| + | |||
| + | .Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 | ||
| + | |||
| + | .Fields.Update | ||
| + | End With | ||
| + | |||
| + | |||
| + | Dim iMsg | ||
| + | set iMsg = CreateObject("CDO.Message") | ||
| + | |||
| + | ' ** UPDATE THE CDOSYS CONFIGURATION ** | ||
| + | Set iMsg.Configuration = objCDOConf | ||
| + | |||
| + | |||
| + | |||
| + | ' apply settings to the message | ||
| + | With iMsg | ||
| + | .To = "test@some_address.com" | ||
| + | .From = "test@your_domain.com" | ||
| + | .Subject = "This is a subject" | ||
| + | .TextBody = "This is the body of the email." | ||
| + | .Send | ||
| + | End With | ||
| + | |||
| + | ' cleanup of variables | ||
| + | Set iMsg = Nothing | ||
| + | %> | ||
| + | </pre> | ||
| + | |||
==.NET Email Sample== | ==.NET Email Sample== | ||
==ColdFusion Email Sample== | ==ColdFusion Email Sample== | ||
Revision as of 21:56, 23 November 2012
Sending Email via Scripts
To send email via code or scripts (ie web pages) you can use either the built in SMTP host smtpmailer.hostek.net which doesn't require a username/password (only from the server) or you can authenticate using your email account, which does require the username and password too.
ASP Email Sample
Here is a sample using CDOSYS to send email from ASP pages. CDOSYS replaces CDONTS on Windows 2003 servers and after.
NOTE: We suggest using CDOSYS for all ASP email applications.
<%
Dim objCDOConf
Set objCDOConf = Server.CreateObject ("CDO.Configuration")
' ** SET AND UPDATE FIELDS PROPERTIES **
With objCDOConf
' ** OUT GOING SMTP SERVER **
' ** SMTP PORT **
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpmailer.hostek.net"
' ** CDO PORT **
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
' ** TIMEOUT **
.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Fields.Update
End With
Dim iMsg
set iMsg = CreateObject("CDO.Message")
' ** UPDATE THE CDOSYS CONFIGURATION **
Set iMsg.Configuration = objCDOConf
' apply settings to the message
With iMsg
.To = "test@some_address.com"
.From = "test@your_domain.com"
.Subject = "This is a subject"
.TextBody = "This is the body of the email."
.Send
End With
' cleanup of variables
Set iMsg = Nothing
%>