Several mail-sending component programs commonly used by ASP
<%
Dim Sendmail,cdoconfig
Sub JMail (Email,topic,mailbody)
On Error Resume Next
Dim JMail
Set jmail=server.createobject ("Jmail.message")
Jmail.silent=true
Jmail.logging=true
jmail.charset= "gb2312"
If Not (Newasp.mailusername = "" Or Newasp.mailpassword = "") Then
Jmail.mailserverusername = Newasp.mailusername ' your mail server login name
Jmail.mailserverpassword = Newasp.mailpassword ' login password
End If
Jmail.contenttype = "Text/html"
jmail.priority = 1
Jmail.maildomain = "govery.cn"
Jmail.from = Newasp.mailfrom ' e-mail address
Jmail.fromname = Newasp.sitename ' site name
Jmail.addrecipient Email
Jmail.subject = Topic
Jmail.body = Mailbody
If Err <> 0 Then
Sendmail= "False"
Else
Jmail.send (newasp.mailserver) ' Send mail server address
Jmail.clearrecipients ()
If Err <> 0 Then
Sendmail= "False"
Else
Sendmail= "OK"
End If
End If
Set jmail=nothing
End Sub
Sub CDONTS (Email,topic,mailbody)
On Error Resume Next
Dim Objcdomail
Set Objcdomail = Server.CreateObject ("CDONTS. NewMail ")
Objcdomail.from = Newasp.mailfrom ' e-mail address
objcdomail.to = Email
Objcdomail.subject = Topic
Objcdomail.bodyformat = 0
Objcdomail.mailformat = 0
Objcdomail.body = Mailbody
If Err <> 0 Then
Sendmail= "False"
Else
Objcdomail.send
If Err <> 0 Then
Sendmail= "False"
Else
Sendmail= "OK"
End If
End If
Set Objcdomail = Nothing
End Sub
Sub AspEmail (Email,topic,mailbody)
On Error Resume Next
Dim Mailer
Set mailer=server.createobject ("Persits.mailsender")
Mailer.charset = "gb2312"
mailer.ishtml = True
Mailer.username = Newasp.mailusername ' Valid user name on the server
Mailer.password = Newasp.mailpassword ' valid password on the server
mailer.priority = 1
Mailer.host = newasp.setting (9)
Mailer.port = 25 ' This option is optional. port 25 is the default value
Mailer.from = Newasp.mailfrom ' e-mail address
Mailer.fromname = Newasp.sitename ' This optional
Mailer.addaddress Email,email
Mailer.subject = Topic
Mailer.body = Mailbody
If Err <> 0 Then
Sendmail= "False"
Else
Mailer.send
If Err <> 0 Then
Sendmail= "False"
Else
Sendmail= "OK"
End If
End If
Set Mailer = Nothing
End Sub
Sub cdomessage (email,topic,mailbody)
on Error Resume Next
if not IsObject (cdoconfig) Then
& Nbsp; call creatcdoconfig ()
end If
dim obj
set obj = Server.CreateObject ("CDO". Message ")
with Obj
set. Configuration = Cdoconfig
. from = Newasp.mailfrom
. to = Email
. Subject = Topic
. TextBody = Mailbody
. Send
end with
set Obj = no
set cdoconfig = Nothing
if err<>0 Then
& Nbsp; sendmail= "False"
else
sendmail= "OK"
end If
End Sub
Sub creatcdoconfig ()
on Error Resume Next
dim Sch
sch = "http://schemas.microsoft.com/ cdo/configuration/"
set cdoconfig = Server.CreateObject (" CDO. Configuration ")
with cdoconfig.fields
. Item (Sch & "smtpserver") = newasp.mailserver '--smtp server
'. Item (Sch & "Smtpserverport") =
. Item (Sch & "sendusing") = 2
. Item (Sch & "smtpaccountname") = Newasp.sitename
. Item (Sch & "sendemailaddress") = Newasp.mailfrom
. Item (Sch & "smtpuserreplyemailaddress") =
. Item (Sch & "smtpauthenticate") = Cdobasic
. Item (Sch & "sendusername") = Newasp.mailusername
. Item (Sch & "Sendpassword") = Newasp.mailpassword
.update
end with
if err< >0 Then
sendmail= "False"
end If
End Sub
%>