using java mail?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: using java mail?

  1. #1
    Join Date
    Jan 2007
    Posts
    3

    using java mail?

    Hi all my Java program comples successfully. I also got the required Java Mail and Activation libraries
    but when I run the program , I see the following error. Please help!
    Exception in thread "main" java.lang.NoSuchMethodError: com.sun.mail.util.Socke
    Fetcher.getSocket(Ljava/lang/String;ILjava/util/Properties;Ljava/lang/String;Z)
    java/net/Socket;
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:3
    0)
    at javax.mail.Service.connect(Service.java:233)
    at javax.mail.Service.connect(Service.java:134)
    at javax.mail.Service.connect(Service.java:86)
    at javax.mail.Transport.send0(Transport.java:162)
    at javax.mail.Transport.send(Transport.java:80)
    at FillinIndices.send(FillinIndices.java:306)
    at FillinIndices.addIndices(FillinIndices.java:237)
    at FillinIndices.main(FillinIndices.java:51)

    Thanks! in advance

  2. #2
    Join Date
    Jan 2007
    Posts
    3

    urgent! somebody please reply to below

    awaiting! reply

  3. #3
    Join Date
    Jan 2007
    Posts
    11

    hi

    if you can show me your code then i think i can help you..

  4. #4
    Join Date
    Dec 2006
    Location
    Kerala,India
    Posts
    51
    which version of java mail API you are using?
    Is it running on Unix based system or on Microsoft?

  5. #5
    Join Date
    Jan 2007
    Posts
    3
    Hi all
    Thanks! for the help
    Found the problem and resolved the issue.
    I had the latest jars from the sun site
    It was actually getting mixed up with other jars(that I used for my other program) that contained a version of this mail api or activation.jar. Once I removed that jar, it worked fine.
    Pasted here is the code that I used to send out email :
    public static void send(String smtpHost, int smtpPort, String from, String to, String subject, String content) throws AddressException, MessagingException
    {

    // Create a mail session
    java.util.Properties props = new java.util.Properties();
    props.put("mail.smtp.host", smtpHost);
    props.put("mail.smtp.port", ""+smtpPort);
    Session session = Session.getDefaultInstance(props, null);

    // Construct the message
    Message msg = new MimeMessage(session);
    msg.setFrom(new InternetAddress(from));
    msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
    msg.setSubject(subject);
    msg.setText(content);

    // Send the message
    Transport.send(msg);
    }

Similar Threads

  1. Replies: 2
    Last Post: 08-31-2009, 01:50 AM
  2. Java book
    By Lou in forum Java
    Replies: 9
    Last Post: 09-19-2007, 06:58 AM
  3. Java vs. .Net. A questionnaire
    By Basil in forum .NET
    Replies: 1
    Last Post: 05-13-2005, 07:46 AM
  4. Re: VB vs. Visual Age for Java
    By JJ in forum Enterprise
    Replies: 1
    Last Post: 07-06-2000, 05:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center