ASP various send mail function code

Source: Internet
Author: User

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
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 = Nothing
Set Cdoconfig = Nothing
If err<>0 Then
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") = 25
. Item (Sch & "sendusing") = 2
. Item (Sch & "smtpaccountname") = Newasp.sitename
. Item (Sch & "sendemailaddress") = Newasp.mailfrom
. Item (Sch & "smtpuserreplyemailaddress") = 25
'. 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.