Ajuda em código

1 resposta
I

esse código está dando um problema de “main”! sou novato em java, mas acho q é algo bem simples, como arrumo? e como funciona akele pacote de “.jar” do jmail???
obrigado

<blockquote>import java.util.Properties;

import javax.mail.<em>;

import javax.mail.internet.</em>;
public class MailExample {

public static void main (String args[]) throws Exception {

String host = args[0];

String from = args[1];

String to = args[2];
// Get system properties 
Properties props = System.getProperties(); 

// Setup mail server 
props.put("mail.smtp.host", host); 

// Get session 
Session session = Session.getDefaultInstance(props, null); 

// Define message 
MimeMessage message = new MimeMessage(session); 

// Set the from address 
message.setFrom(new InternetAddress(from)); 

// Set the to address 
message.addRecipient(Message.RecipientType.TO, 
  new InternetAddress(to)); 

// Set the subject 
message.setSubject("Hello JavaMail"); 

// Set the content 
message.setText("Welcome to JavaMail"); 

// Send message 
Transport.send(message);

}
}

1 Resposta

leofernandesmo

Cola o erro aqui…mas tenta tb
Tirar esse “throws Exception” e coloca um “Try Catch”…

Criado 27 de novembro de 2006
Ultima resposta 27 de nov. de 2006
Respostas 1
Participantes 2