Solved

Sending an email thru javax.mail. facing some problem

Posted on 2002-07-30
3
310 Views
Last Modified: 2013-11-24
hi
This is my code and when i run it i'm getting an error stating

Exception in thread "main" java.lang.NoClassDefFoundError: javax/activation/DataSource
        at MailTest.<init>(MailTest.java:31)
        at MailTest.main(MailTest.java:48)
I tried finding out other programs, but that doesn't give particualr exception.
i think the code is perfect
i didn't understand the "javax/activation/datasource"
 i need it very urgently.
i have attached my code also.


regards
Snehal

/*******************************************************/
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
import javax.naming.Context;
import javax.naming.InitialContext;

public class MailTest
{
     String mailHost = "mail.business-functions.com";
     String to = "snehal@bfn.com";
     String from = "snehal@yahoo.com";
     String subject = "This is Test Mail Thru Java Mail API";
     String body = "This is Test Mail to check whether the Java Mail APi is Working or not. This is prototype developed by Snehal K gandhi of Business Functions Software Solutions Pvt Ltd.";
     Provider provider;

     public MailTest()
     {
          try
          {
               Properties props = System.getProperties();
               props.put("mail.smtp.host", mailHost);
               Session session = Session.getInstance(props,null);
               Message message = new MimeMessage(session);
               message.setFrom(new InternetAddress(from));
               message.setRecipients(Message.RecipientType.TO,new InternetAddress[]{new InternetAddress(to)});
               message.setSubject(subject);
               message.setContent(body, "text/plain");
               Transport.send(message);
               System.out.println("Mail has been Sent");
          }
          catch(MessagingException me)
          {
               System.out.println("2. Error While Sending the Mail and the exception is : " + me.toString());
          }

     }

     public static void main(String arg[])
     {
          new MailTest();
     }
}

/*******************************************************/
0
Comment
Question by:snehalkgandhi
[X]
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
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 7187353
You need activation.jar which can be downloaded at:
http://java.sun.com/products/javabeans/glasgow/jaf.html
0
 

Author Comment

by:snehalkgandhi
ID: 7187522
Thank u

regards
Snehal
0
 
LVL 92

Expert Comment

by:objects
ID: 7187538
Only a 'B' ??
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
How  can  i  resolve  HTTP Status 404 -? 8 59
ejb entity bean example 2 35
Crystal Reports Licensing Questions 4 60
Java List 4 35
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

756 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