Java Mail sends emails

Source: Internet
Author: User

Problem description:

Use the javaMail package to automatically send emails

Solution:

(1) The jar package to be referenced using javamail is as follows:

Note:

To test in Win7, you only need to import the javax. mail. jar package. To test in WinXP, You need to import the javax. mail. jar package and javax. activation. jar package.

(2) preparations before sending an email

(3) set basic mail Information

(3.1) include additional email information settings

Note:

Set the mail content, which consists of the mail sender, mail subject, and mail content.

(3.2) email settings that do not contain attachments

Note:

Overload function, set email information, does not contain attachments

(4) send an email

Note:

To send an email, First connect to the email server, and then set the Email Recipient Information (which can contain multiple Email recipients)

(5) interface function for adding email attachments and body (step (3) call)

(5.1) Add email body

(5.2) Add email attachments

Source code:

References:

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.