'*************************************** ************
'Function name: isobjinstalled
'Usage: Check whether the component has been installed
'Parameter: strclassstring ---- component name
'Return value: True ---- installed
'False ---- Not Installed
'*************************************** ************
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
'*************************************** ***********
'Function name: Sendmail
'Use: Use the jmail component to send emails
'Parameter: mailtoaddress ---- recipient address
'Mailtoname ----- Recipient Name
'Subject ----- topic
'Mailbody ----- mail content
'Fromname ----- sender's name
'Mailfrom ----- sender address
'Priority ----- mail priority
'*************************************** ***********
Function Sendmail (email, mailtoname, subject, mailbody, fromname, mailfrom, priority)
On Error resume next
Dim jmail
Set jmail = server. Createobject ("jmail. Message ")
If err then
Sendmail = "<br> <li> the jmail component is not installed </LI>"
Err. Clear
Exit Function
End if
Jmail. charset = "gb2312" 'email code
Jmail. Silent = true
Jmailmsg. Logging = true
Jmail. contenttype = "text/html" 'mail body format
Jmail. serveraddress = MailServer 'smtp server used to send emails
'If the server requires SMTP authentication, you also need to specify the following parameters
Jmail. mailserverusername = mailserverusername 'logon Username
Jmail. mailserverpassword = mailserverpassword 'logon Password
Jmail. maildomain = maildomain 'domain name (specify domain.com
Jmail. addrecipient email, mailtoname' recipient
Jmail. Subject = subject 'topic
Jmail. hmtlbody = mailbody 'mail body (in HTML format)
Jmail. Body = mailbody 'mail body (in plain text format)
Jmail. fromname = fromname 'sender's name
Jmail. From = mailfrom 'sender email
Jmail. Priority = Priority 'mail level. 1 is urgent, 3 is normal, and 5 is low.
Jmail. Send MailServer
Sendmail = jmail. errormessage
Jmail. Close
Set jmail = nothing
End Function
'*************************************** *****
'Function name: isvalidemail
'Usage: check the validity of the email address
'Parameter: email ---- email address to be checked
'Return value: True ---- valid email address
'False ---- invalid email address
'*************************************** *****
Function isvalidemail (email)
Dim names, name, I, C
Isvalidemail = true
Names = Split (email ,"@")
If ubound (names) <> 1 then
Isvalidemail = false
Exit Function
End if
For each name in names
If Len (name) <= 0 then
Isvalidemail = false
Exit Function
End if
For I = 1 to Len (name)
C = lcase (mid (name, I, 1 ))
If instr ("abcdefghijklmnopqrstuvwxyz _-.", c) <= 0 and not isnumeric (c) then
Isvalidemail = false
Exit Function
End if
Next
If left (name, 1) = "." Or right (name, 1) = "." Then
Isvalidemail = false
Exit Function
End if
Next
If instr (names (1), ".") <= 0 then
Isvalidemail = false
Exit Function
End if
I = Len (names (1)-faster Rev (names (1 ),".")
If I <> 2 and I <> 3 then
Isvalidemail = false
Exit Function
End if
If instr (email, "...")> 0 then
Isvalidemail = false
End if
End Function