0% found this document useful (0 votes)
26 views2 pages

03 Javamail Sendmail EXC

This document provides instructions for sending an email using the Javamail API. It outlines setting up a J2EE project with an EAR and WAR application. The WAR will contain a servlet that uses Javamail API classes to send an email to an SMTP server. It also includes a form to collect sender/recipient details. The steps include setting the classpath, coding the servlet to look up a mail session, create a message, and send the email. The project is then built, deployed, and tested using a web form.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

03 Javamail Sendmail EXC

This document provides instructions for sending an email using the Javamail API. It outlines setting up a J2EE project with an EAR and WAR application. The WAR will contain a servlet that uses Javamail API classes to send an email to an SMTP server. It also includes a form to collect sender/recipient details. The steps include setting the classpath, coding the servlet to look up a mail session, create a message, and send the email. The project is then built, deployed, and tested using a web form.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Javamail API, Exercises

Unit: Javamail
Topic: Send mail using the Javamail API

At the conclusion of this exercise, you will be able to:


• Send an e-mail using the Javamail API.

1. Development Objectives
Creating a J2EE Project and use the Javamail API to send an e-mail message. The
J2EE Project will contain an EAR application and a WAR application. The Web
Application will have a Servlet which will make use of the Javamail API Classes
to send an e-mail message to a SMTP Server. The Web Project also contains a
HTML form used to get the user input for receiver’s e-mail address, Subject and
Message Text.

2. Prerequisites
2-1 You have configured the Java mail client service tab in the Visual
Administrator and have set the SMTP Server and sender’s details. (It is
necessary to restart the server once the java mail client service properties
are changed)
2-2 You have launched the Netweaver Developer Studio.
2-3 You have selected the J2EE perspective.

3. Exercise Guide

3-1 Open the project template in the exercise directory called


InitialProject_Javamail.
3-2 Setup classpath – Add mail.jar to the classpath
3-3 Add code to the doGet method of the servlet
3-3-1 Obtain JNDI Context
3-3-2 Lookup a Javamail Session
3-3-3 Check the SMTP Server and sender’s details and print them to
the browser.
3-3-4 Create a message and set the details (Sender’s name,
Recipient’s name, Subject, Body).
3-3-5 Send the mail and print the response to the browser.

4. Deploying the Application


4-1 Right Click on the JavamailProjectWAR Project and “Choose Build Web
Archive”.
4-2 Right Click on the JavamailProjectEAR Project and “Choose Build
Application Archive”.
4-3 Right Click on the JavamailProjectEAR.ear file and “Choose Deploy to J2EE
Engine”

5. Testing the Application


Open Web Browser and Navigate to this URL http://localhost:<http-
port>/Javamail/SendMail.html

Enter the details on the form and hit Ok to send the mail.

You might also like