Professional Documents
Culture Documents
03 Javamail Sendmail SOL
03 Javamail Sendmail SOL
03 Javamail Sendmail SOL
Unit: Javamail
Topic: Send 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. Result
As a result of the exercise you will be able to compose and send an e-mail
message.
3. Prerequisites
3-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)
3-2 You have launched the Netweaver Developer Studio.
3-3 You have selected the J2EE perspective.
4. Overview Developing
JavamailProjectEAR
The EAR Project which
contains the web project.
JavamailProjectWAR
The WAR Project which
contains the Servlet which uses the
Javamail API.
Javamail
The Servlet used for sending e-
mails using the Javamail API classes.
SendMail.html
HTML form to compose a
message. This form posts its data to
the Javamail Servlet.
message.setRecipients(Message.RecipientType.TO, new
InternetAddress[] { new
InternetAddress(request.getParameter("Recipient")) });
message.setSubject(request.getParameter("Subject"));
message.setContent(request.getParameter("Message"),
"text/plain");
4-6 Send the message
// Step 5. Send the message
Transport.send(message);