First, there must be an error to continue the declaration on error Resume Next
Then try the resume JMail instance:
Dim JMail
Set jmail=server.createobject ("Jmail.message")
The instance is judged, and if the component is not successfully installed, no instance is created:
If JMail is nothing Then
Response.Write "Not Supported"
Else
Response.Write "Support"
End If
Other components are equally processed, very simple.
It's best to deal with the global file, which is not as cumbersome as it is used.
The best way to do this is to put the message in a table and then talk about sending things.
Copy Code code as follows:
Function isobjinstalled (strclassstring)
On Error Resume Next
isobjinstalled = False
ERR = 0
Dim Xtestobj
Set xtestobj = Server.CreateObject (strclassstring)
If 0 = Err Then isobjinstalled = True
Set xtestobj = Nothing
ERR = 0
End Function
Judging code:
If isobjinstalled ("Jmail.message") =true then{
If isobjinstalled ("Jmail.message") =true Then
Sendstat = JMail ("* * @jb51. NET", "customer messages from the Internet", "End If
}
JMail Letter function
Copy Code code as follows:
' ============================================
' JMail Send mail
' ============================================
Function JMail (Mailto,mailtopic,mailbody,mailcharset,mailcontenttype)
' Entry parameters:
' MailTo Recipient email address
' Mailtopic Mail theme
' Mailbody message body (content)
' MailCharSet message character set, such as GB2312 or Us-ascii
' Mailcontenttype message body format, such as Text/plain or text/html
' Return value:
' String, return OK after sending success, unsuccessful return error message
' Use method:
' 1 set a constant, that is, a variable that starts with a const
' 2 use a letter similar to the following code
' Dim Sendstat
' Sendstat = JMail ("aa@163.com", "Test JMail", "This is a <br/> test letter!" "," GB2312 "," text/html ")
' Response.Write Sendstat
' *************** set constants to start as needed *****************
Dim Constfromnamecn,constfromnameen,constfrom,constmaildomain,constmailserverusername,constmailserverpassword
CONSTFROMNAMECN = "Lottery Net" ' Chinese name of the sender (used when sending Chinese mail), such as ' John '
Constfromnameen = "Bc5" ' letter in English name (used when sending English mail), for example ' Zhangsan '
Constfrom = "jb51@163.com" ' sender's email address, such as ' zhangsan@163.com '
Constmaildomain = "smtp.163.com" SMTP server address, such as smtp.163.com
Constmailserverusername = "jb51@163.com" SMTP server's mailbox login name, such as ' Zhangsan '. Note to be consistent with the sender's email address!
Constmailserverpassword = Mailbox Login password for "www.jb51.net" SMTP server
' *************** to set constant end *****************
'-----------------------------The following need not be changed------------------------------
On Error Resume Next
Dim Myjmail
Set Myjmail = Server.CreateObject ("Jmail.message")
myjmail.logging = False ' Log
Myjmail.isoencodeheaders = False ' message header does not use ISO-8859-1 encoding
myjmail.contenttransferencoding = "base64" ' message encoding set to Base64
Myjmail.addheader "Priority", "3" ' Add headers, do not change!
Myjmail.addheader "Msmail-priority", "Normal" ' Add headers, do not change!
Myjmail.addheader "Mailer", "Microsoft Outlook Express 6.00.2800.1437" ' Add headers, do not change!
Myjmail.addheader "MimeOLE", "produced by Microsoft mimeole V6.00.2800.1441" ' Add headers, do not change!
Myjmail.charset = MailCharSet
Myjmail.contenttype = Mailcontenttype
If UCase (MailCharSet) = "GB2312" Then
Myjmail.fromname = CONSTFROMNAMECN
Else
Myjmail.fromname = Constfromnameen
End If
Myjmail.from = Constfrom
Myjmail.subject = Mailtopic
Myjmail.body = Mailbody
Myjmail.addrecipient MailTo
Myjmail.maildomain = Constmaildomain
Myjmail.mailserverusername = Constmailserverusername
Myjmail.mailserverpassword = Constmailserverpassword
Myjmail.send Constmaildomain
Myjmail.close
Set myjmail=nothing
If ERR Then
Jmail=err.description
Err.Clear
Else
Jmail= "OK"
End If
On Error Goto 0
End Function