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: