Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sending an email thru javax.mail. facing some problem

Posted on 2002-07-30
3
Medium Priority
?
315 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 150 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
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:
Suggested Courses

661 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