> Read the tutorial. It actually pretty easy. The JavaDoc is not very
> useful until you understand how all the pieces fit together.

Signature
Beware the False Authority Syndrome
Just a comment, althought not perfect, I find the amount of free and
quality Java examples to be above other systems I've worked on. I
think the examples that do exist are of unusually high quality. They
are way above Apple C examples, way above C# examples on ... forget the
site now... and Java code is usually much more readable then C++ and
many other languages.
So much quality & free stuff.
The moral of the story is look for examples when Javadoc is inadaquate.
If you define the following variables as String: username, password,
SMTP_HOST_NAME, SMTP_PORT, SSL_FACTORY, assign appropriate values, and
also somewhere in the code, before invocation, put
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); the
following will send emails for you:
public void sendSSLMessage(String recipients[], String subject,
String message, String from) throws MessagingException {
boolean debug = false;
Properties props = new Properties();
props.put("mail.smtp.host", SMTP_HOST_NAME);
props.put("mail.smtp.auth", "true");
props.put("mail.debug", "false");
props.put("mail.smtp.port", SMTP_PORT);
props.put("mail.smtp.socketFactory.port", SMTP_PORT);
props.put("mail.smtp.socketFactory.class", SSL_FACTORY);
props.put("mail.smtp.socketFactory.fallback", "false");
Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication
getPasswordAuthentication() {
return new PasswordAuthentication(username,
password);
}
});
session.setDebug(debug);
Message msg = new MimeMessage(session);
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);
InternetAddress[] addressTo = new
InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++) {
addressTo[i] = new InternetAddress(recipients[i]);
}
msg.setRecipients(Message.RecipientType.TO, addressTo);
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport.send(msg);
}
Have a fun day, http://www.geocities.com/opalpaweb/, opalpa@gmail.com
> That is true for a lot of the more exotic parts of the java library, and
> many third party libraries as well. Javadoc should include more code
> samples.
JavaMail comes with a whole directory of example code. Why clutter the
documentation with that? The only thing IMHO missing in JavaMail's
javadoc are pointers to these examples - for those programmers who don't
check what they actually installed.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
zero - 16 Jan 2006 11:15 GMT
Thomas Weidenfeller <nobody@ericsson.invalid> wrote in news:dqfokn$7em$1
@news.al.sw.ericsson.se:
> The only thing IMHO missing in JavaMail's
> javadoc are pointers to these examples
That would work too. For example a lot of the Swing GUI classes have links
to the (very good) Swing tutorial. That is a very good solution imo.

Signature
Beware the False Authority Syndrome