Ola Vivian,
Ao receber seu email recortei o fonte desta pagina e compilei com jdk 1.1.8 sem
problemas, so foi preciso arrumar uns comentarios que ficaram mal posicionados
no fonte. Em seguida envie um e-mail para mim mesmo sem problemas. Que
compilador Java voce esta utilizando? Ainda n�o testei com o Jdk 1.2.
[]s, Grego
____________________Separador de Resposta____________________
Assunto: [SouJava-J] Ref: Java & E-mail
Autor: <[EMAIL PROTECTED]>
Data: 11/11/99 14:06
Compilei o exemplo que o Ricardo Grego enviou (sobre Email) e o codigo esta
com seguintes erros:
Wrong number of arguments in constructor:
URL u = new URL("mailto:"+to); // Create a mailto: URL
Method openConnection() not found in class URL.
URLConnection c = u.openConnection(); // Create a URLCOnnection for
it
Wrong number of arguments in constructor.
end = new URL("http","java.sun.com","index.html");
Nao consigo arrumar!!! Verifiquei os construtores de URL na documentacao do
Java e nao consigo encontrar o erro!!! Alguem poderia me ajudar???? Esse
ultimo erro eh super estranho pois a linha nao esta no codigo!!!
Obrigada
Vivian
[EMAIL PROTECTED]
-----Original Message-----
From: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Wednesday, November 10, 1999 10:35 AM
Subject: Re:Java & E-mail
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
--------------------------- LISTA SOUJAVA ---------------------------
http://www.soujava.org.br - Sociedade de Usu�rios Java da Sucesu-SP
[para sair da lista: http://www.soujava.org.br/forum/cadastrados.htm]
---------------------------------------------------------------------
Received: from server07.brasifrj.com.br [172.16.2.7] by brasifrj.com.br (ccMail Link
to SMTP R8.30.00.7)
; Thu, 11 Nov 1999 17:07:30 -0200
Return-Path: <[EMAIL PROTECTED]>
Received: (qmail 12110 invoked by alias); 11 Nov 1999 19:07:53 -0000
Delivered-To: [EMAIL PROTECTED]
Received: (qmail 12091 invoked from network); 11 Nov 1999 19:07:19 -0000
Received: (ofmipd 209.68.1.162); 11 Nov 1999 19:06:57 -0000
Received: (from slist@localhost) by ansuz.pair.com (8.9.1/8.6.12) id OAA26521 for
[EMAIL PROTECTED]; Thu, 11 Nov 1999 14:06:46 -0500 (EST)
Resent-Date: Thu, 11 Nov 1999 14:06:46 -0500 (EST)
Resent-Message-ID: <[EMAIL PROTECTED]>
Resent-From: [EMAIL PROTECTED]
Resent-Sender: [EMAIL PROTECTED]
Date: 11 Nov 1999 16:51:25 -0200
Message-ID: <009001bf2c75$c19c3960$b578a8c0@vivian>
From: "Vivian Rodrigues Fiales" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
X-Envelope-To: [EMAIL PROTECTED]
Old-X-Envelope-To: <[EMAIL PROTECTED]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.72.3110.1
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Subject: [SouJava-J] Ref: Java & E-mail
X-Mailing-List: <[EMAIL PROTECTED]> archive/latest/255
X-Loop: [EMAIL PROTECTED]
Precedence: list