Solved

Sending an email thru javax.mail. facing some problem

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

708 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

16 Experts available now in Live!

Get 1:1 Help Now