A simple Jmail mail sent a message, I made this code a specific annotation today and added the other two formats, and raised a few simple examples: first is Jmail.smtpmail. Core code:
<% Set jmail = server.createObject ("jmail.smtpmail") 'Create a jmail object jmail.silent = true' jmail does not throw exception error, the return value is false and true jmail.logging = true 'Enables logging JMail.Charset = "GB2312" message code is the code for Simplified Chinese jmail.contettype = "text / html" 'mail format HTML Jmail.Serveradraddress = "server address" "Send mail server JMail.addRecipient Email' mail The recipient jmail.sendername = "sendername" 'Mail sender's name Jmail.Sender = "email address" "Email Address" mail address jmail.priority = 1' email emergency procedure, 1 is the fastest, 5 is The slowest, 3 is the default value jmail.subject = "mail subject" message title jmail.body = "mail body" 'mail content jmail.addrecipientbcc email' Pixabay address JMail.addRecipientcc Email 'mail CcCcc EMAIL' Address Jmail.execute () 'Executing Mail Send JMail.Close' Off Mail Object%>
W3 Jmail4.3 Components Redes its internal structure - Use the Message object instead of the original single object Jmail.smtpmail sends mail, some methods require authentication (such as 163, yahoo et al), can solve the following method: <% Set jmail = server.createObject ("jmail.message") 'Establishing a message of the object jmail.silent = true' masked exception error, return false with true two-value J mail.logging = true 'Enable mail log jmail.charset = " GB2312 "'Mail text code is the national standard jmail.contenttype =" text / html "message format is HTML format jmail.addrecipient email' mail recipient's address Jmail.From =" email from for sender "'sender E-mail address jmail.mailServerUserName = "username of email" logged in the user name Jmail.mailServerPassword = "password of email" required by the mail server JMail.Subject = "mail subject" mail Title jmail.body = "mail body" "The content jmail.prority = 1 'email emergency program, 1 is the fastest, 5 is the slowest, 3 is the default value Jmail.send (" Server Address ") Mail Send (via mail server address) jmail.close () Close Object%> Talking about Microsoft's self-contained CDONTS components:
<% Set cdomail = server.createObject ("cdonts.newmail") 'Establishing a mail object cdomail.subject = "mail subject"' mail title cdomail.from = "sender's mail" 'sender's address cdomail.to = "email Will from "'" Recipient's address cdomail.body = "mail body" message content cdomail.send' Perform send%>
This method is the easiest, and it also brings certain problems, that is, there are very few servers open this service!
We write procedures, in general, it is to say to code modularization, so convenient maintenance, it is also convenient to transplant. Therefore, I am here to write this email into a subsidy. When you call it, you can call it directly (of course, if you are happy to write a function, it is ok, this is mainly interesting):
<% 'Parameter Description' Subject: Mail Title 'Mailaddress: Address Server Address, such as SMTP.163.com' Email: Recipient Email Address' Sender: Sender Name 'Content: Mail content' FROMER: Send Human Email Address Sub SendAction (Subject, Maildress, Email, Sender, Content, Fromer) Set Jmail = Server.createObject ("Jmail.smtpmail") 'Create a Jmail Object Jmail.silent = true' Jmail Will not throw exception error The return value is false with true jmail.logging = true 'Enables the use of log jmail.charset = "gb2312"' mail text to Simplified Chinese Jmail.conteType = "text / html" mail format is HTML JMail. ServerAddress = mailaddress' sends a mail server Jmail.addrecipient email 'mail recipient jmail.sendername = sender' mail sender's name Jmail.Sender = FROMER 'Mail mail address Jmail.Priority = 1' email emergency Program, 1 is the fastest, 5 is the slowest, 3 is the default jmail.subject = Subject 'mail title jmail.body = content' mail content 'Since it is not used to copy, this is blocked If you need it, you can restore the address of 'Jmail.AddRecipientBCC Email' mobile recipient's address 'Jmail.AddRecipientc Email' Mail.Execute () 'execution email send jmail.close' close Mail object END SUB 'An example of calling this SUB DIM strsubject, strmail, strmailadress, strsnder, strcontent, strfromer strsubject = "This is a test mail" strcontent = "Jmail component sent by Jmail! "Strembing@eyou.com" strmail = "runbing@eyou.com" strmailaddress = "mail.ubbcn.com"
Call SendAction (STRSUBJECT, STRMAILADRESS, STREMAIL, STRSENDER, STRCONTENT, STRFROMER)%>
The above is a rough insight for my email code, forget everyone!