ASP Mail
From KOP KB
This is more of a testing script for trying out different types of email there are you can try through asp.
Contents
CDO
elseif u_method ="CDOSYS" then
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "localhost"
.update
End With
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.From = s_from
.To = u_email
.Subject = "Testing email"
.TEXTBody = "CDOSYS aka CDO.Message worked"
.send
End With
Response.write "To: " & u_email
Response.write "From: " & s_from
Set cdoMessage = Nothing
Set cdoConfig = Nothing
CDONTS
elseif u_method = "CDONTS" then
Dim MyBody
Dim MyCDONTSMail
Set MyCDONTSMail = CreateObject("CDONTS.NewMail")
MyCDONTSMail.From= s_from
MyCDONTSMail.To= u_email
MyCDONTSMail.Subject="This is a Test"
MyBody = "testing email" & vbCrLf
MyBody = MyBody & "CDONTS seems fine" & vbCrLf
MyCDONTSMail.Body= MyBody
MyCDONTSMail.Send
set MyCDONTSMail=nothing
Response.write "To: " & u_email
Response.write "From: " & s_from
ASPMAIL AND QMAIL
if u_method = "ASPMAIL" or u_method = "QMAIL" then
set Mailer = Server.CreateObject("SMTPsvg.Mailer")
if u_method = "QMAIL" then
'This is pretty much setting qmail right here
'if its not set then pretty much its aspmail sending it
Mailer.QMessage = "true"
Mailer.Subject = "Testing ASPQmail"
else
Mailer.Subject = "Testing ASP Mail"
end if 'ASPQMAIL
Mailer.FromName = "Test"
Mailer.FromAddress= s_from
Mailer.RemoteHost = "localhost"
Mailer.AddRecipient "Test",u_email
Mailer.BodyText = "This is a Test"
Mailer.SMTPLog = server.mappath("./smtp.log")
if Mailer.SendMail then
Response.write "To: " & u_email
Response.write "From: " & s_from
else
Response.Write "Mail send failure. Error was " & Mailer.Response
end if 'sendmail success
Full Script
<form action=mailtest.asp method=post>
<div>Enter the email you would like to send to: <input type=text name=email> using the mailer:
<select name=mailobject>
<option value="CDONTS">CDONTS</option>
<option value="ASPMAIL">ASPMAIL</option>
<option value="QMAIL">ASPQMAIL</option>
<option value="CDOSYS">CDO.Message</option>
</select>
<input value=submit type=submit>
</form>
<%
u_email = Request.Form("email")
if u_email <>"" then
u_method=Request.form("mailobject")
s_servername = Request.ServerVariables("SERVER_NAME")
s_from = "mailtest@" & s_servername
if u_method = "ASPMAIL" or u_method = "QMAIL" then
set Mailer = Server.CreateObject("SMTPsvg.Mailer")
if u_method = "QMAIL" then
'This is pretty much setting qmail right here
'if its not set then pretty much its aspmail sending it
Mailer.QMessage = "true"
Mailer.Subject = "Testing ASPQmail"
else
Mailer.Subject = "Testing ASP Mail"
end if 'ASPQMAIL
Mailer.FromName = "Test"
Mailer.FromAddress= s_from
Mailer.RemoteHost = "localhost"
Mailer.AddRecipient "Test",u_email
Mailer.BodyText = "This is a Test"
Mailer.SMTPLog = server.mappath("./smtp.log")
if Mailer.SendMail then
Response.write "To: " & u_email
Response.write "From: " & s_from
else
Response.Write "Mail send failure. Error was " & Mailer.Response
end if 'sendmail success
elseif u_method = "CDONTS" then
Dim MyBody
Dim MyCDONTSMail
Set MyCDONTSMail = CreateObject("CDONTS.NewMail")
MyCDONTSMail.From= s_from
MyCDONTSMail.To= u_email
MyCDONTSMail.Subject="This is a Test"
MyBody = "testing email" & vbCrLf
MyBody = MyBody & "CDONTS seems fine" & vbCrLf
MyCDONTSMail.Body= MyBody
MyCDONTSMail.Send
set MyCDONTSMail=nothing
Response.write "To: " & u_email
Response.write "From: " & s_from
elseif u_method ="CDOSYS" then
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "localhost"
.update
End With
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.From = s_from
.To = u_email
.Subject = "Testing email"
.TEXTBody = "CDOSYS aka CDO.Message worked"
.send
End With
Response.write "To: " & u_email
Response.write "From: " & s_from
Set cdoMessage = Nothing
Set cdoConfig = Nothing
end if
end if
%>