• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error running javamail code

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"
 
LOOK! OVER THERE! (yoink) your tiny ad is now my tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic