Ola Carlos,

Aqui vai um exemplo que encontrei no livro "Java Examples in a Nutshell". Esse
livro eu recomendo embora seja para a versao 1.1. Os exemplos contidos nele voce
pode baixar em http://www.oreilly.com/catalog/jenut/

Obs.: Ainda n�o testei esse exemplo, mas deve funcionar.

[]s, Grego

// This example is from _Java Examples in a Nutshell_.  http://www.oreilly.com)
// Copyright (c) 1997 by David Flanagan
// This example is provided WITHOUT ANY WARRANTY either expressed or implied.
// You may study, use, modify, and distribute it for non-commercial purposes.
// For any commercial use, see http://www.davidflanagan.com/javaexamples

import java.io.*;
import java.net.*;

/**
 * This program sends e-mail using a mailto: URL
 **/
public class SendMail {
  public static void main(String[] args) {
    try {
      // If the user specified a mailhost, tell the system about it.
      if (args.length >= 1) System.getProperties().put("mail.host", args[0]);

      // A Reader stream to read from the console
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

      // Ask the user for the from, to, and subject lines
      System.out.print("From: ");
      String from = in.readLine();
      System.out.print("To: ");
      String to = in.readLine();
      System.out.print("Subject: ");
      String subject = in.readLine();

      // Establish a network connection for sending mail
      URL u = new URL("mailto:" + to);      // Create a mailto: URL 
      URLConnection c = u.openConnection(); // Create a URLConnection for it
      c.setDoInput(false);                  // Specify no input from this URL
      c.setDoOutput(true);                  // Specify we'll do output
      System.out.println("Connecting...");  // Tell the user what's happening
      System.out.flush();                   // Tell them right now
      c.connect();                          // Connect to mail host
      PrintWriter out =                     // Get output stream to mail host
        new PrintWriter(new OutputStreamWriter(c.getOutputStream()));

      // Write out mail headers.  Don't let users fake the From address
      out.println("From: \"" + from + "\" <" +
                  System.getProperty("user.name") + "@" + 
                  InetAddress.getLocalHost().getHostName() + ">");
      out.println("To: " + to);
      out.println("Subject: " + subject);
      out.println();  // blank line to end the list of headers

      // Now ask the user to enter the body of the message
      System.out.println("Enter the message. " + 
                         "End with a '.' on a line by itself.");
      // Read message line by line and send it out.
      String line;
      for(;;) {
        line = in.readLine();
        if ((line == null) || line.equals(".")) break;
        out.println(line);
      }

      // Close the stream to terminate the message 
      out.close();
      // Tell the user it was successfully sent.
      System.out.println("Message sent.");
      System.out.flush();
    }
    catch (Exception e) {  // Handle any exceptions, print error message.
      System.err.println(e);
      System.err.println("Usage: java SendMail [<mailhost>]");
    }
  }
}



____________________Separador de Resposta____________________
Assunto:    Java & E-mail 
Autor:  <[EMAIL PROTECTED]>
Data:       09/11/99 16:02

Prezados Javaneses,

Estou desenvolvendo um software de Controle de Estoque de Suprimentos de
Inform�tica na Intranet utilizando Applets e Servlets.

Gostaria de, ap�s processar o atendimento de uma Requisi��o efetuada
pelo Usu�rio, enviar um E-mail ao pr�prio e ao seu chefe imediato
registrando a opera��o.

Todos os campos necess�rios e E-mails dos envolvidos est�o dispon�veis
mas ainda n�o sei como proceder, em Java, para enviar o tal e-mail.

Li uma mensagem recentemente na lista referenciando a classe JavaMail.
Baixei a documenta��o mas n�o tive tempo de explor�-la, por ser muito
extensa e por ainda estar "capinando" com a l�gica orientada a objetos e
a sintaxe b�sica do Java.

Gostaria de uma orienta��o sobre o assunto e se � poss�vel utilizar
algum m�todo mais simples, como a classe URL, por exemplo, com o
cl�ssico comando:

mailto:[EMAIL PROTECTED]?subject=assunto&body=corpo&cc=outro_usuari
[EMAIL PROTECTED]

Agrade�o antecipadamente pela orienta��o,

[]'s

Carlos Campos
[EMAIL PROTECTED]
Analista de Sistemas / Bolsista PCI
MCT/CNPq  - CETEM - Centro de Tecnologia Mineral
Fone: 0xx21 5607222 - Ext. 358


 

Received: from server07.brasifrj.com.br [172.16.2.7] by brasifrj.com.br (ccMail Link 
to SMTP R8.30.00.7)
        ; Tue, 09 Nov 1999 19:04:02 -0200
Return-Path: <[EMAIL PROTECTED]>
Received: (qmail 23233 invoked by alias); 9 Nov 1999 22:03:29 -0000
Delivered-To: [EMAIL PROTECTED]
Received: (qmail 23227 invoked from network); 9 Nov 1999 22:02:36 -0000
Received: (ofmipd 209.68.1.162); 9 Nov 1999 22:02:14 -0000
Received: (from slist@localhost) by ansuz.pair.com (8.9.1/8.6.12) id QAA20099 for 
[EMAIL PROTECTED]; Tue, 9 Nov 1999 16:02:42 -0500 (EST)
Resent-Date: Tue, 9 Nov 1999 16:02:42 -0500 (EST)
Resent-Message-ID: <[EMAIL PROTECTED]>
Resent-From: [EMAIL PROTECTED]
Resent-Sender: [EMAIL PROTECTED]
Date: 9 Nov 1999 18:53:14 -0300
Message-ID: <[EMAIL PROTECTED]>
From: "Carlos Campos" <[EMAIL PROTECTED]>
To: "'Lista Java BR'" <[EMAIL PROTECTED]>,
  "'Lista SouJava'      " <[EMAIL PROTECTED]>
X-Envelope-To: [EMAIL PROTECTED]
Old-X-Envelope-To: <[EMAIL PROTECTED]>
Subject: Java & E-mail
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.1960.3)
Content-Type: text/plain;
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
X-Mailing-List: <[EMAIL PROTECTED]> archive/latest/172
X-Loop: [EMAIL PROTECTED]
Precedence: list

Responder a