Use JMail to send emails in the project, and use jmail to send emails in the project.
1. Add the JMail component. In Solution Explorer of vs, right-click Add reference, select Browse, and select the jmail. dll file. The added JMail component is displayed in the Bin folder.
Jmail and jmail tools
I haven't updated my blog for a long time. It's really a serious procrastination. It's terrible. Update a tool class first. I wrote a tool for sending emails. I don't need to talk much about the code.
Import lombok. extern. slf4j. slf4j; import java. util. properties; import javax. mail. *; import javax. mail. internet. addressException; import javax. mail. internet. internetAddress; i
Some time ago has sent a simple jmail mail email code, today this code to make a specific annotation, and add two other formats of code, with a few simple examples:
The first is Jmail.smtpmail's core code:
Program code
Set JMail = Server.CreateObject ("JMail. SmtpMail ")" Creates a JMail object
Jmail.silent = True '
A friend who has learned asp may know that the jmail component uses a common mailbox sending function in asp. to call the jmail function in php, we need to use the com component for operations. let's first introduce it.
Friends who have learned asp may know that the jmail component uses a common mailbox sending function in asp. to call the
Send detailed ASP and jmail to send emailsCodeA simple jmail email code was sent some time ago. Today, we will make a specific annotation for this code and add the code in two other formats, here are a few simple examples:
The core code of jmail. smtpmail is as follows:
Copy code The Code is as follows: Set jmail =
Details:
JmailMain Parameter List
(1) Body (letter body): String
For example:
Jmail. Body = "the content of the Form filled by the user can be taken from. "
(2) charset (character set, default: "US-ASCII"): String
For example:
Jmail. Charset = "US-ASCII"
(3) contenttransferencoding: String
Specifies the encoding method for content transfer. The default value is "quoted-printable"
For example:
Jmail|jmail
Cdonts
Set Cdomail = Server.CreateObject ("CDONTS. NewMail ")" Create mail objectCdomail. Subject = "Mail Subject" ' Message headersCdomail. from = "Sender ' s Mail" ' sender's addressCdomail. to = "Email would from" ' Recipient's addressCdomail. BODY = contents of mail bodyCdomail. Send ' performs sending%>
This method of sending mail is the simplest, but also brings a certain problem, that is
Some time ago there was a simple JMail e-mail sent the code, today, the code to make a specific note, and add two other formats of code, with a few simple examples:The first is the core code of Jmail.smtpmail: Set jmail = Server.CreateObject (" JMail. SmtpMail ") ' Creates a JMail object Jmail.silent = True '
I sent a simple jmail email some time ago.
Code Today, we will make a specific annotation for this code, and add the code in the other two formats, and give a few simple examples:
The core code of jmail. smtpmail is as follows:
Program Code
Set jmail = server. Createobject ("jmail. smtpmail") 'creates a
Send all the more detailed ASP and JMail implementation of the code to send mail, some time ago has sent a simple jmail mail message code, today the code to do a specific annotation, and added two other formats of code, with a few simple examples:The first is Jmail.smtpmail's core code:
Copy Code code as follows:
Set JMail = Server.CreateObject ("
Let's introduce the format first.
The code is as follows
Copy Code
$Jmail = new COM ("Jmail.message"); Instantiate a JMail object$Jmail->silent=true; When set to True JMail does not prompt for error only returns true and False$Jmail->logging = fal
Note: For more information, see jmail instructions. I think this is enough. Don't ask me if you have any questions. For server reasons, I only use cdonts to send emails, sorry... (1) Body (letter body): String For example, jmail. Body = "the content of the Form filled by the user can be taken from. " (2) charset (character set, default: "US-ASCII"): String Example:
Some time ago has sent a simple jmail mail email code, today this code to make a specific annotation, and add two other formats of code, with a few simple examples:
The first is Jmail.smtpmail's core code:
Set JMail = Server.CreateObject ("JMail. SmtpMail ")" Creates a JMail object
Jmail.silent = True '
Roughly as follows:
The 1,pop3 object is the operation of the POP3 mail receiving server.
2,messages object, which is an object about a collection of messages.
The 3,message object, which is the object of the message, is the most commonly used object of the JMail component to send mail messages and receive message information.
4,header object, which is the object associated with the message header.
5,recipients object that is the object that receives
recent projects require sending emails. jmail has not been used for a long time and is not officially supported by jmail. net version, so some problems are encountered, to avoid detours and write down the following content, my jmail version is 4.3 you need to extract jmail in. 1. download jmail4.3 and search for the
Many times, errors occur when sending emails using jmail. Common causes include:
1. The email sending server address is incorrect. If the email address is sent in 163, the server address should be smtp.163.com.
2. Many mail servers need to verify the mailbox Login Name (for example: laifangsong@163.com) and password (123456), if both are not submitted, the send will also fail.
3. The sender's email address and the sender's login name are inconsistent.
The call is done. It took several days to complete.> _ Many examples of jmail sending emails on the Internet do not show how to send attachments, or do not specify how to send embedded attachments (such as embedding attachments into HTML letters)
When I was so depressed, I finally went to the "Dark flowers". Oh, Yeah ~~!!!
In fact, the most important thing is to comment out this sentence.
'Jmail. contenttyp
Sub Sendmail (mail_to, mail_subject, mail_body)
'On error resume next
Dim jmail
Userip = request. servervariables ("http_x_forwarded_for ")
If userip = "" Then userip = request. servervariables ("remote_addr") 'get the real IP Address
Set jmail = server. Createobject ("jmail. Message ")
Jmail. Silent = true
Some time ago has sent a simple jmail mail email code, today this code to make a specific annotation, and add two other formats of code, with a few simple examples:
The first is Jmail.smtpmail's core code:
Set JMail = Server.CreateObject ("JMail. SmtpMail ")" Creates a JMail objectJmail.silent = True '
function Sendmail (mailtoaddress, mailtoname, subject, mailbody, fromname, mailfrom) 'function parameter description (recipient address, Recipient Name (optional), topic, mail content, sender name (optional), sender address) 'on error resume next dim jmail, MailServer, flag set jmail = server. createobject ("jmail. message ") If err then Sendmail = false e
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.