05-04-2013, 04:07 PM
JSP - SENDING EMAIL
JSP - SENDING.pdf (Size: 49.57 KB / Downloads: 15)
INTRODUCTION
To send an email using a JSP is simple enough but to start with you should have JavaMail API and Java Activation
Framework (JAF) installed on your machine.
You can download latest version of JavaMail (Version 1.2) from Java's standard website.
You can download latest version of JavaBeans Activation Framework JAF (Version 1.0.2) from Java's standard
website.
Download and unzip these files, in the newly created top level directories you will find a number of jar files for both
the applications. You need to add mail.jar and activation.jar files in your CLASSPATH.
Send a Simple Email:
Here is an example to send a simple email from your machine. Here it is assumed that your localhost is connected to the
internet and capable enough to send an email. Same time make sure all the jar files from Java Email API package and
JAF package ara available in CLASSPATH.
Send an HTML Email:
Here is an example to send an HTML email from your machine. Here it is assumed that your localhost is connected to
the internet and capable enough to send an email. Same time make sure all the jar files from Java Email API package
and JAF package ara available in CLASSPATH.
This example is very similar to previous one, except here we are using setContent() method to set content whose second
argument is "text/html" to specify that the HTML content is included in the message.