sending email jsp

Posted on 2003-03-12
Medium Priority
Last Modified: 2010-04-01
Can some one please give me a sample mail jsp/bean !!!!!!
Question by:rax_uk2000
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

rakeshkumar_12 earned 300 total points
ID: 8120272
This code sends mail using java mail

import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.FileDataSource;
import javax.activation.DataHandler;

// This method send a message
     public boolean sendJavaMail(String host, String from, String to,
String cc, String bcc, String subject, String message, String mimeType)
    Properties props = new Properties();
    props.put("mail.smtp.host", host);

    Session session = Session.getDefaultInstance(props, null);

      //Message msg = new MimeMessage(session);
      MimeMessage msg = new MimeMessage(session);

      InternetAddress from2 = new InternetAddress(from);

      InternetAddress[] to2 =  InternetAddress.parse(to);
      msg.setRecipients(Message.RecipientType.TO, to2);

      if(cc != null)
          InternetAddress[] cc2 =  InternetAddress.parse(cc);
          msg.setRecipients(Message.RecipientType.CC, cc2);

      if(bcc !=null)
          InternetAddress[] bcc2 =  InternetAddress.parse(bcc);
          msg.setRecipients(Message.RecipientType.BCC, bcc2);

      // Create subject

      // Create and fill the first message part
      MimeBodyPart mbp1 = new MimeBodyPart();
      mbp1.setContent(message, mimeType);

      // Create the Multipart and its parts to it
      Multipart mp = new MimeMultipart();

      // Add the Multipart to the message

               return true;
    catch (MessagingException ex)
               return false;

Good luck


Author Comment

ID: 8120291
thanks that will do nicely !

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hey fellow admins! This time, I have a little fairy tale for you. As many tales do, it starts boring and then gets pretty gory. I hope you like it. TL;DR: It is about an important security matter, you should read it if you run or administer Windows …
This month, Experts Exchange’s free Course of the Month is focused on CompTIA IT Fundamentals.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question