ASP sends an email with Jmail, CDO

zhaozj2021-02-16  73

A simple Jmail message sent a simple Jmail message, I made this code a specific annotation today, and added two different formats, and raised a few simple examples:

The first is the core code of jmail.smtpmail:

<%

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" code code is Simplified Chinese

Jmail.contentType = "text / html" "The format of the message is HTML

Jmail.Serveraddress = "Server Address" "Servers sending mail

Jmail.addrecipient email 'recipient

Jmail.SenderName = "sendername" 'Mail sender's name

Jmail.Sender = "email address" "email address" mail sender's email address

Jmail.Priority = 1 'email emergency procedure, 1 is the fastest, 5 is the slowest, 3 is default

Jmail.subject = "mail subject" 标 邮 邮 邮

Jmail.Body = "mail body" "content"

JMail.AddrecipientBCC Email 'Pixabay Address

Jmail.addrecipientcc email 'email Cc

Jmail.execute () 'Executing Mail Send

Jmail.close 'Close the email object

%>

[Ctrl A All Choose and Copy]

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 email-type object jmail.silent = true' mask exception error, return false with true two-value jmail.logging = true 'Enables mail log jmail.charset = "GB2312" mail text code is the national standard jmail.conteType = "text / html" message format is HTML format Jmail.addRecipient email 'mail recipient's address jmail.From = "email from for sender" " Human e-mail address jmail.mailServerUsername = "username of email" logging in user name Jmail.mailServerPassword = "password of email" required by logging in to the password required by logging in the mail server Jmail.Subject = "mail subject" The title jmail.body = "mail body" "Mail" version of the email urgent program, 1 is the fastest, 5 is the slowest, 3 is the default value jmail.send ("Server Address") ' Perform email (via mail server address) jmail.close () 'Close Object%> [Ctrl A All Choose and Copy]

Talk about the method of sending a letter from Microsoft's own 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%>

[Ctrl A All Choose and Copy]

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: Email 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, MAILADDRESS, Email, Sender, Content, Fromer) Set Jmail = Server.createObject ("Jmail.smtpmail") 'Create a Jmail Object Jmail.silent = true' jmail Will not throw exception error, return value Enable the use of log jmail.chail.logging = true 'to use the log jmail.charset = "GB2312" The code for the mail text is Simplified Chinese Jmail.contentType = "text / html" message format is HTML Jmail.ServeraddRESS = Mailaddress' Send Mail server jmail.addrecipient email 'mail recipient jmail.sendername = sender' mail sender's name Jmail.Sender = FROMER 'Email the email address jmail.Priority = 1' email emergency procedure, 1 is the most Fast, 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 two sentences are blocked, if you have If you need, you can restore the address of 'Jmail.addrecipientBCC Email' mobile phone 'JMail.addRecipientc Email' Mail.Execute () 'execution message to send jmail.close' Close the email object END SUB ' = "JMail component sends the test is successful!" calls this Sub example Dim strSubject, strEmail, strMailAdress, strSender, strContent, strFromerstrSubject = "this is a test message with JMAIL sent" strContent strEmail = "runbing@eyou.com" strFromer = "Runbing@eyou.com" strmailaddress = "mail.ubbcn.com" Call SendAction (strsubject, strmailaddress, stresince, strsnder, strcont ENT, StrfroMER)

%>

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

New Post(0)