A simple mail class [send it with jmail components]

xiaoxiao2021-03-06  46

<% '******************************************************* ****************************************** * Sound: If you use this program Please keep this information '* Program Name: TEVMAIL' * function: Send email (Jmail4.3 version on the server) '* Development date: 2005-01-13' * Advantages: If you write Jmail programs Set a lot of values, such as server addresses, passwords, user names, and more, after using this class, the shortest '* can only send mail only three-line statement. For details, please see the example below.' * Example: '* Set abc = new jmail '* abc.to = "Your mailbox address"' * abc.send '* ' * You can test it, use The above four sentences have established an ASP page, then run, your email will go out! '* But if I need to set the message title, sender, content, etc. What should I do? Please refer to the following parameters.' * Specific parameters: '* .serveraddress = "SMTP.126.com"' Set your own mail server '* .username = "weili.cn" "mail server username' * .password =" ****** * "'Mail server password' * .from =" weili.cn "'sender address' * .fromname =" Liwei "' sender named '* .to =" weili.cn@126.com "' The name of the person * .subject = "test" 'mail topic' * .body = "test" message content '* Error handle processing:' * .number 'After sending this value, use this value to determine whether the transmission is successful, value <= 0 When sending success' * .Rror 'If there is an error, you can use this value to extract the error message' * .about 'Current copyright information of the current class, in order to respect the results of others, please do not modify, thank you!' *** *********************************************************** ******************* *************** Class TevMail Private ObjMail Private sUserName Private sPassword Private sFrom Private sFromName Private sSubject Private sBody Private sTo Private sServer Private iNumber Private sError Private sAbout Private Sub Class_Initialize () sAbout = "Program Name: Mail Send Class
"& _" Writing: Tellov
"& _" date: 2005-01-13
"& _" Note: Welcome to this class, if you need help or Have a good suggestion, please contact me, thank you!

"& _" QQ: 40386978
"& _" email: weili.cn@126.com
"SUSERNAME =" "spassword =" "sfrom =" "sfromname =" "SSUBJECT =" "SSUBJECT =" "sbody =" "STO =" "SSERVER =" "Inumber = 0 serror =" "

Set ObjMail = Server.CreateObject ( "JMail.Message") with ObjMail .silent = true .Logging = true .Charset = "gb2312" .MailServerUserName = "tevmail" .MailServerPassword = "tevmail" .From = "tevmail@126.com ".Fromname =" tellov ".subject =" Welcome to use JMail class! ".Body =" This class is written by Tellov, welcome to exchange learning, weili.cn @ 126.com "End with end sub private sub class_terminate () SET ObjMail = nothing end Sub public Property Let ServerAddress (sInput) sServer = sInput end Property public Property Let UserName (sInput) sUserName = sInput end Property public Property Let Password (sInput) sPassword = sInput end Property public Property Let [To] (sInput) sTo = sInput end Property Public Property Let From (sInput) sFrom = sInput end Property Public Property Let FromName (sInput) sFromName = sInput end Property PubLic Property Let Subject (sInput) sSubject = sInput end Property Public Property Let Body (sInput) sBody = SINPUT End Property Public Property Get Number Number = Inumber End Property Public Property Get Error Error = sError end Property Public ProPerty Get About About = sAbout end Property Private Function CheckAddress (sAddress) Dim regEx, RegExpTest Set regEx = New RegExp regEx.Pattern = "^ [/ w /.] @ {1} /w /.{1}/w $ "regEx.IgnoreCase = false RegExpTest = regEx.test (sAddress) if RegExpTest then CheckAddress = true else CheckAddress = false end if end Function Private Function CheckMail () if sServer =" "then iNumber = -1 SERROR = SERROR & "

Your [Server Address] did not fill in
"end if srror =" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" THEN Inumber = -1 serror = serror & "Your [server password] did not fill in
" end if if sfrom = "" THENUMBER = -1 SERROR = SERROR & "Your [sender address] did not fill in
"End if if sfromname =" "THEN INUMBER = -1 SERROR = SERROR &" Your [sender] did not fill in
"end if sssube =" "" "" " [Email Title] No
"End if IF SBODY =" "THEN INUMBER = -1 SERROR = SERROR &" Your [Mail Content] did not fill in
"End ifness" "" " = "The following options you have not filled, the program will send the mail with the default configuration
" & serror end ifick the code "& seen" = 101 ser = "The recipient address format is incorrect
" End ififf " SFROM <> "" and SUSERNAME <> "" and sserver <> "" and INSTR (SFROM, SUSERNAME) = 0 and INSTR (SUSERNAME, SFROM) = 0 THEN Inumber = 102 SERROR = "send People server username and sender address do not match
"end if if inumber <= 0 THEN CHECKMAIL = true else checkmail = false end if End function pu BLIC FUNCTION Send () on error resume next if Checkmail () THEN with objmail if sfrom <> "" "" "" "" "" "" "" "". Subject = SSUBJECT END IF IF SBODY <> ""

转载请注明原文地址:https://www.9cbs.com/read-68734.html

New Post(0)