Je kunt mail versturen vanaf onze windows servers door gebruik te maken van het Windows CDOSYS object.
Je vindt meer informatie hierover op http://www.w3schools.com/asp/asp_send_email.asp
Voorbeeld .aspx programma. Plak deze code in een .aspx file.
<!--
'Email versturen met SMTP mail via port 25 met gebruik making van CDOSYS
'Deze ASP pagina gebruikt CDOSYS om SMTP mail te versturen via poort 25 van de mailserver die hieronder genoemd wordt. De emailafhandeling wordt afgehandeld door die mailserver. Dat doet dit script niet.
-->
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
' Verstuur door verbinding te maken met poort 25
Dim iMsg
Dim iConf
Dim Flds
Dim strHTML
Dim strSmartHost
Const cdoSendUsingPort = 2
iMsg = CreateObject("CDO.Message")
iConf = CreateObject("CDO.Configuration")
Flds = iConf.Fields
' Vertel de CDOSYS configuratie velden om poort 25 van de SMTP server te gebruiken.
With Flds
' Dit stukje gebruiken als de smtp mail server op dezelfde servr is:
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
' Dit stukje gebruiken als de smtp server ergen anders is
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "servernaam(zoiets als mail.uwdomein.xx)"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername) = "mailbox gebruikersnaam"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "uw mailbox wachtwoord"
.Update
End With
' Maak even een HTML body
strHTML = "<HTML>"
strHTML = strHTML & "<HEAD>"
strHTML = strHTML & "<BODY>"
strHTML = strHTML & "<b> Dit is een test HTML body</b></br>"
strHTML = strHTML & "</BODY>"
strHTML = strHTML & "</HTML>"
' Wijzigig de message settings
With iMsg
.Configuration = iConf
.To = "naar@emailadres"
.From = "van@emailadres"
.Subject = "Dit is een test met een CDOSYS bericht (Sent via Port 25)"
.HTMLBody = strHTML
.Send
End With
' Opruimen variabelen
iMsg = Nothing
iConf = Nothing
Flds = Nothing
%>
<P> </P>
</BODY>
</HTML>
<!--
--------------------------- Hieronder een .ASP voorbeeld -----------------------------------------
<%
Dim objMessage
Dim objConf
Dim objFields
Dim strHTML
set objMessage = CreateObject("CDO.Message")
set objConf = CreateObject("CDO.Configuration")
Set objFields = objConf.Fields
objFields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objFields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
objFields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
objFields.Update
strHTML = "<HTML>"
strHTML = strHTML & "<HEAD>"
strHTML = strHTML & "<BODY>"
strHTML = strHTML & "<b> This is the test HTML message body</b></br>"
strHTML = strHTML & "</BODY>"
strHTML = strHTML & "</HTML>"
Set objMessage.Configuration = objConf
objMessage.To = "<TO>"
objMessage.From = "<FROM>"
objMessage.Subject = "This is a test CDOSYS message (Sent via Port 25)"
objMessage.HTMLBody = strHTML
objMessage.Send
Set objMessage = Nothing
Set objConf = Nothing
Set objFields = Nothing
%>