Hi, I create a simple program to send an email : ------------------------------------------------------------ Properties props = new Properties(); // Setup mail server props.put("mail.smtp.host", hostName); // Get session session = Session.getDefaultInstance(props, null); Provider[] providers = session.getProviders(); System.out.println("Provider List !!"); for (int i = 0; i < providers.length; i++) System.out.println(providers.getProtocol() + " " + providers.getClassName() + " " + providers.getVendor() + " " + providers.getVersion()); // Define message MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(sender)); for (int i = 0; i < recipents.length; i++) { message.addRecipient(Message.RecipientType.TO, new InternetAddress (recipents)); } message.setSubject(subject); message.setText(content); // Send message Transport.send(message); ------------------------------------------------------------ In that app, some of variables are missing to simplify the codes. Well the codes running well, and is able to send the email if I run it under the IDE like JBuilder or any IDE.. But if I put it into JAR file then I can't execute because of : No providers available.. Thus these lines print nothing ... for (int i = 0; i < providers.length; i++) System.out.println(providers.getProtocol() + " " + providers.getClassName() + " " + providers.getVendor() + " " + providers.getVersion()); How can I set the provider ? Thx...
Pete Lyons
Ranch Hand
Joined: Aug 18, 2002
Posts: 109
posted
0
I think this is just because you don't have Sun's mail implementation jar file on your classpath or in the extensions directory. Change your classpath to make sure you've got the javax.mail classes as well as the com.sun.mail classes.
Matthew X. Brown
Ranch Hand
Joined: Nov 08, 2000
Posts: 165
posted
0
You also need to make sure you have the activation.jar in your path