Ver Mensaje Individual
  #5 (permalink)  
Antiguo 21/03/2007, 16:53
amerika
 
Fecha de Ingreso: enero-2004
Mensajes: 12
Antigüedad: 20 años, 3 meses
Puntos: 0
Re: Problemas al ejecutar desde simbolo del sistema

Gracias a todos por respopnder, ya intenté lo siguiente y me sigue dando el mismo error:

* java -cp <tuclasspath> <nombre de la clase>.
* modificar el classpath

Mi código es le siguiente a ver si alguien puede ayudarme:

import java.util.Date;
import java.sql.*;
import java.util.Properties;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Message;
import javax.mail.Transport;
import javax.mail.internet.*;



public class SendMail
{

/** Método inicializar la clase SendMail
* @param args
*/
public static void main(String args[]){
SendMail ejecutaMail = new SendMail();
String mensaje = "El servidor con la IP: 192.9.201.144 no está funcionando, favor de revisarlo";
String titulo = "Monitoreo de servidores";
ejecutaMail.sendMail(mensaje, titulo);
}

/** Método que realiza el envio del correo electronico
* @param mensaje En este parámetro se deberá de enviar el contenido del mensaje
* @param tituloe En este parámetro se deberá de enviar el título del correo
*/
public void sendMail(String mensaje, String titulo) {
//Dirección IP del servidor de e-mail.
String host="192.9.200.6";
//Dirección del emisor.
String from = "[email protected]";
//Dirección del destinatario.
String to= "[email protected]";
//Título del Correo electrónico.
String subject = titulo;

//Mensaje del Correo electrónico, se agregan tags de HTML
String messagetext = "<p align=left>"+
"<html><body><font face='Tahoma'><b>Reporte del estado de Servers</b></font></p>"+
"<ul>"+
"<li>"+
"<p align='left'>"+
"<font face='Tahoma'><b>"+mensaje+"&nbsp;&nbsp; </b></font></li>"+
"</ul>"+
"<p>&nbsp;</p>"+
"</html></body>";
boolean sessionDebug = false;
Properties props = System.getProperties();

props.put("mail.host",host);
props.put("mail.transport.protocol","smtp");
Session mailSession = Session.getDefaultInstance(props, null);
mailSession.setDebug(sessionDebug);
Message msg =new MimeMessage(mailSession);

try{
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {
new InternetAddress("[email protected]"),
new InternetAddress("[email protected]"),
new InternetAddress("[email protected]"),
new InternetAddress("[email protected]"),
new InternetAddress("[email protected]")
};
msg.setRecipients(Message.RecipientType.TO,address );
msg.setContent(messagetext, "text/html; charset=\"iso-8859-1\"");
msg.setSubject(subject);
msg.setSentDate(new Date());
Transport.send(msg);
System.out.println("Mensaje enviado");
}catch(MessagingException mE){mE.printStackTrace();}
}
}