'*************************************** **************************************** *****
'Author: loster (OICQ: 181306) [do not delete this information if it is reprinted. Thank you!]
'Function name: send_email ()
'Purpose: Use the jmail4.3 component to send e-mail
'Parameter:
'Email: Type: string. Purpose: Address of the email recipient.
'E _ subject: Type: string. Role: subject of a letter.
'Information: Type: string. Role: content of the letter.
'S _ type: Type: Boolean value. Purpose: whether the email is in HTML format. True is in HTML format. False is in text format.
'C _ m_chk: Type: Boolean value. Role: whether the SMTP server requires authentication
'If the message is sent successfully, the function returns true. Otherwise, false is returned.
'*************************************** **************************************** *****
Function send_email (email, e_subject, information, s_type, c_m_chk)
Const c_email = "'sender's mailbox
Const c_hostname = "'sender's name
Const c_smtp = "smtp.xxx.com" 'smtp server address
Const c_m_user = "'If the SMTP server needs to authenticate the identity, enter the user name
Const c_m_pass = "" enter the password
Dim sender
Err. Clear
On Error resume next
If email = "" or information = "" Or e_subject = "" then
Send_email = false
Exit Function
End if
Set sender = server. Createobject ("jmail. Message ")
Sender. Logging = true
Sender. From = c_email
Sender. fromname = c_hostname
Sender. addrecipient email
Sender. Subject = e_subject
If s_type = false then
Sender. appendtext Information
Else
Sender. appendhtml Information
End if
Sender. maildomain = c_smtp
If c_m_chk = true then
Sender. mailserverusername = c_m_user
Sender. mailserverpassword = c_m_pass
End if
Sender. Priority = 1
Sender. Send (c_smtp)
If err. Number <> 0 then
Send_email = false
Else
Send_email = true
End if
Err. Clear
End Function