Solved

Sending an email thru javax.mail. facing some problem

Posted on 2002-07-30
3
306 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
  • 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Application launch issue with Apache Tomcat 5 18
eclipse shortcuts 9 45
why cannot we forward request once the response is committed 2 33
more than one jdk and one jre 1 30
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

929 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now