esta es la excepcion
Código HTML:
[#|2010-07-28T18:26:26.646-0600|SEVERE|sun-glassfish|null|_ThreadID=87;_ThreadName=Thread-3;|java.lang.RuntimeException: javax.mail.internet.ParseException|#]
[#|2010-07-28T18:26:26.646-0600|SEVERE|sun-glassfish|null|_ThreadID=87;_ThreadName=Thread-3;| at Solicitudes.MailTask.run(MailTask.java:84)|#]
[#|2010-07-28T18:26:26.647-0600|SEVERE|sun-glassfish|null|_ThreadID=87;_ThreadName=Thread-3;| at java.lang.Thread.run(Thread.java:619)|#]
[#|2010-07-28T18:26:26.647-0600|SEVERE|sun-glassfish|null|_ThreadID=87;_ThreadName=Thread-3;|Caused by: javax.mail.internet.ParseException|#]
[#|2010-07-28T18:26:26.647-0600|SEVERE|sun-glassfish|null|_ThreadID=87;_ThreadName=Thread-3;| at javax.mail.internet.ContentType.<init>(ContentType.java:96)|#]
[#|2010-07-28T18:26:26.648-0600|SEVERE|sun-glassfish|null|_ThreadID=87;_ThreadName=Thread-3;| at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1291)|#]
[#|2010-07-28T18:26:26.648-0600|SEVERE|sun-glassfish|null|_ThreadID=87;_ThreadName=Thread-3;| at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2074)|#]
[#|2010-07-28T18:26:26.648-0600|SEVERE|sun-glassfish|null|_ThreadID=87;_ThreadName=Thread-3;| at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:2042)|#]
[#|2010-07-28T18:26:26.649-0600|SEVERE|sun-glassfish|null|_ThreadID=87;_ThreadName=Thread-3;| at Solicitudes.MailTask.run(MailTask.java:80)|#]
[#|2010-07-28T18:26:26.649-0600|SEVERE|sun-glassfish|null|_ThreadID=87;_ThreadName=Thread-3;| ... 1 more|#]
Código HTML:
public void enviarCorreo(){ System.out.println("Enviar Correo"); String subject=solicitud.getAsunto_Solicitud(); String text=solicitud.getDescripcion_Solicitud(); listaCorreo=new BD_Solicitudes().consultaCorreoUsuarios(listaCorreo, mail); //String mail=""+mail.getEmail(); for(int i=0; i<listaCorreo.size();i++){ try{ MailTask task = new MailTask("[email protected]","mail",null,subject,text,"server"); new Thread(task).start(); }catch(AddressException e){ e.printStackTrace(); } } }
Código HTML:
import EnviarMail.*; import javax.mail.*; import java.util.Properties; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; public class MailTask implements Runnable { //smtp.cybermatsa.com.mx public static final String SERVER = "[email protected]"; private InternetAddress from; private InternetAddress[] to; private String subject; private String text; private String mailServer; public MailTask(String from, String to, String cc, String subject, String text, String mailServer) throws AddressException { if (from == null) { throw new NullPointerException("from es nulo"); } if (from.length() == 0) { throw new IllegalArgumentException("from esta vacio"); } if (to == null) { throw new NullPointerException("to es nulo"); } if (to.length() == 0) { throw new IllegalArgumentException("to esta vacio"); } if (subject == null) { throw new NullPointerException("subject es nulo"); } if (subject.length() == 0) { throw new IllegalArgumentException("subject esta vacio"); } if (text == null) { throw new NullPointerException("text es nulo"); } if (text.length() == 0) { throw new IllegalArgumentException("text esta vacio"); } if (mailServer == null) { throw new NullPointerException("mail server es nulo"); } if (mailServer.length() == 0) { throw new IllegalArgumentException("mail server esta vacio"); } this.from = new InternetAddress(from); if (cc != null) { this.to = new InternetAddress[] { new InternetAddress(to), new InternetAddress(cc) }; } else { this.to = new InternetAddress[] { new InternetAddress(to) }; } this.subject = subject; this.text = text; this.mailServer = mailServer; } public void run() { try { Properties props = new Properties(); props.put("mail.smtp.host", "[email protected]"); Session session = Session.getInstance(props); Message msg = new MimeMessage(session); msg.setContent(text, ""); msg.setFrom(from); msg.setRecipients(Message.RecipientType.TO, to); msg.setSubject(subject); msg.saveChanges(); Transport.send(msg); // LogWriter.getLogger().info("Mensaje enviado..."); } catch (MessagingException e) { throw new RuntimeException(e); } } }