JAVAMail question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • akoymakoy
    New Member
    • Oct 2006
    • 42

    #1

    JAVAMail question

    im new to the the mail stuff and smtp stuff .. im trying to make a module to send email ... here is my code and the error it returns is:

    Exception in thread "main" java.lang.NoCla ssDefFoundError : javax/activation/DataSource
    at src.lacrown.Mai l.main(Mail.jav a:35)

    this line:MimeMessag e message = new MimeMessage(s);
    what could be wrong? or what am i missing?

    thanks in advance


    import java.util.*;
    import javax.mail.*;

    import javax.mail.inte rnet.*;

    public class Mail {
    static String msgText1 = "This is a message body.\nHere's line two.";
    static String msgText2 = "This is the text in the message attachment.";

    public static void main(String[] args) throws MessagingExcept ion {
    Properties props = new Properties();
    props.put("laco ronahotels.com" , "lacoronahotels .com");
    Session s = Session.getInst ance(props,null );


    InternetAddress from = new InternetAddress ("akoymakoy@yah oo.com");
    InternetAddress to = new InternetAddress ("akoymakoyg@ya hoo.com");

    MimeMessage message = new MimeMessage(s);
    message.setFrom (from);
    message.addReci pient(Message.R ecipientType.TO , to);

    message.setSubj ect("Your subject");
    message.setText ("Your text");
    Transport.send( message);
    }
    }
  • MarkoKlacar
    Recognized Expert Contributor
    • Aug 2007
    • 296

    #2
    Hi,

    There must exist a lot of tutorials on how to send mail using Java, this one is pretty straight forward, match you code aginst it and you'll get your solution.

    Good luck

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by akoymakoy
      im new to the the mail stuff and smtp stuff .. im trying to make a module to send email ... here is my code and the error it returns is:

      Exception in thread "main" java.lang.NoCla ssDefFoundError : javax/activation/DataSource
      at src.lacrown.Mai l.main(Mail.jav a:35)

      this line:MimeMessag e message = new MimeMessage(s);
      what could be wrong? or what am i missing?
      What is the Java version you're running? For the activation framework you need
      at least Java 1.4

      kind regards,

      Jos

      Comment

      • akoymakoy
        New Member
        • Oct 2006
        • 42

        #4
        hi im using java 1.5

        Comment

        Working...