Eu acabei de baixar o examples.zip e compilar o SendMail.java, mas continua
dando aqueles erros. Pode ser um problema de versao? Estou usando o Java
1.2.
Obrigada,
Vivian
-----Original Message-----
From: Eduardo Issao Ito <[EMAIL PROTECTED]>
To: Vivian Rodrigues Fiales <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Thursday, November 11, 1999 5:56 PM
Subject: Re: [SouJava-J] Ref: Java & E-mail
Vivian,
eu acabei de compilar e funcionou perfeitamente.
Experimente baixar o programa original:
http://www.oreilly.com/catalog/jenut/examples/examples.zip
Vivian Rodrigues Fiales wrote:
>
> 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
--------------------------- 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]
---------------------------------------------------------------------