sending email jsp

Can some one please give me a sample mail jsp/bean !!!!!!
rax_uk2000Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rakeshkumar_12Commented:
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);
    session.setDebug(false);

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

      InternetAddress from2 = new InternetAddress(from);
      msg.setFrom(from2);

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

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

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

      // Create subject
      msg.setSubject(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();
      mp.addBodyPart(mbp1);

      // Add the Multipart to the message
      msg.setContent(mp);

      Transport.send(msg);    
               
               return true;
    }
    catch (MessagingException ex)
    {
      ex.printStackTrace();
               
               return false;
    }
  }


Good luck

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rax_uk2000Author Commented:
thanks that will do nicely !
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.