ASP uses components in wire mail

xiaoxiao2021-03-06  14

First, jmail.smtpmail's 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 Send mail, some methods require authentication (such as 163, Yahoo et al), can solve the following method:

<% Set jmail = server.createObject ("jmail.message") 'Establishing an object jmail.silent = true' shielding exception error, returning false with true two-value J mail.logging = true 'Enable mail log jmail.charset = "GB2312" message 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" People's 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" 'The title jmail.body = "mail body" "The content jmail.prority = 1' mail urgent program, 1 is the fastest, 5 is the slowest, 3 is the default Jmail.send (" Server Address) 'Execute Mail Send (via mail server address) Jmail.close () Close Object%> Second, Microsoft's self-contained CDONTS components send information:

<% 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! Write procedures, in general, it is to say to code modularization, so convenient maintenance, it is 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)

%>

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

New Post(0)