Check whether the component is installed. Use the jmail component to send an email.

Source: Internet
Author: User
Tags valid email address

'*************************************** ************
'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

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.