![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
#4
|
|||
|
|||
|
Ya esta ya funciona, por si alguien le interesa:
Código:
try
{
Properties props = new Properties();
props.put("mail.smtp.host",host);
Session s = Session.getInstance(props,null);
MimeMessage message = new MimeMessage(s);
InternetAddress fromIA = new InternetAddress(from);
message.setFrom(fromIA);
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject(subject);
MimeMultipart mp = new MimeMultipart();
mp.setSubType("related");
//Dividim en dos el mail, mbp1 es el text i mbp2 es l'adjunt
MimeBodyPart mbp1= new MimeBodyPart();
mbp1.setText("Aqui possem el text");
MimeBodyPart mbp2 = new MimeBodyPart();
FileDataSource fds = new FileDataSource(archivo);
mbp2.setDataHandler(new DataHandler(fds));
mbp2.setFileName(fds.getName());
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);
message.setContent(mp);
message.setSentDate(new java.util.Date());
Transport.send(message);
}catch (Exception e){
log("Application ERROR: problem sending an email: "+e.getMessage());
}
Última edición por dec fecha: 10-07-2006 a las 14:58:44. |
|
|
Temas Similares
|
||||
| Tema | Autor | Foro | Respuestas | Último mensaje |
| mail con ShellExecute y archivo adjunto | MarioATamborini | Internet | 4 | 28-06-2007 00:39:20 |
| Enviar un email con un archivo adjunto | Turboleta | Internet | 9 | 31-07-2006 19:55:16 |
| Enviar email con copia y adjunto con indy | cmena | Internet | 4 | 01-10-2005 01:14:00 |
| bajar adjunto de un mail | zastilla | Internet | 0 | 22-06-2005 14:50:49 |
| Enviar correo con dato adjunto | jncrls | Internet | 1 | 06-05-2003 15:26:33 |
|