Several mail-sending component programs commonly used by ASP

Source: Internet
Author: User

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
%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.