JavaMail API - Sending Emails

Now that we have a fair idea about JavaMail API and its core classes, let us now write a simple programs which will send simple email, email with attachments, email with HTML content and email with inline images.

Basic steps followed in all the above scenarios are as below:

  • Get the Session object.

  • Compose a message.

  • Send the message.

In the following sections we have demonstrated simple examples of: