Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

error running javamail code  RSS feed

 
bhaskarjoshi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I am able to send email from Outlook Express using SMTP server installed on my pc.
Like this I want to send email from a java code using JavaMail.
The code is as follows

import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
import java.lang.*;
public class JDMailer
{
public static void main(String [] args) throws Exception
{
Properties props = new Properties();
props.put("mail.smtp.host","localhost");
Session session = Session.getDefaultInstance(props,null);
session.setDebug(true);

MimeMessage msg = new MimeMessage(session);
InternetAddress addressfrom = new InternetAddress ("anil_n@sancharnet.in");
msg.setFrom(addressfrom);
Address addressTo = new InternetAddress("basappa_jodalli@rediffmail.com");
msg.setRecipient(Message.RecipientType.TO,addressTo);
msg.setSubject("dddd");
msg.setContent("uuuuuooooooooyyyyyyyyyyyrrrrrrrrr","text/plain");
Transport transport = session.getTransport("smtp");
transport.send(msg);
}
}
I am getting this error
Exception in thread �main� java.lang.NoClassDefFoundError :com/sun/mail/util/SharedByte ArrayInputStream
at JDMailer.main(JDMailer.java:15)
I have set the classpath to include j2ee.jar from my Sun\AppServer\lib directory of J2EE.
Pls help me out immediately
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bhaskarjoshi ,
Thank you for visiting to JavaRanch. Unfortunately, you name does not comply with our Naming Policy. Please change your display name to comply. (We are looking for a first name and a last name)
Thanks!
 
Himanshu Pathak
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
never worked with the mail API.
dont you think there should be no space in the class name.
"SharedByte ArrayInputStream"
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!