|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Feb 2003
Città: Formia
Messaggi: 1545
|
java mail
L'email me la invia anche con l'allegato ma ho un pb
Non riesco a far interpretare il messaggio in html. public String sendAllegato(String host, String from, String to, String subject, String mes, String mimetype,String filename) { String errore=""; try{ File f=new File(filename); // 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 Message message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); message.setSubject(subject); // Create the multi-part Multipart multipart = new MimeMultipart(); // Create part one BodyPart messageBodyPart = new MimeBodyPart(); // Fill the message messageBodyPart.setText(mes); // Add the first part multipart.addBodyPart(messageBodyPart); // Part two is attachment messageBodyPart = new MimeBodyPart(); DataSource source = new FileDataSource(f); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(filename); // Add the second part multipart.addBodyPart(messageBodyPart); // Put parts in message message.setContent(multipart); // Send message Transport.send(message); System.out.println("Finito"); }catch(Exception e) { errore=e.getMessage(); } return errore; } |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Jun 2001
Città: Alessandria (provincia)
Messaggi: 4772
|
Se intendi che non riesci a formattare in HTML il testo, prova a vedere se qua c'è qualcosa che ti può servire (l'ho estratto dal codice che uso io, ora analizzare dove inserirlo nel tuo mi viene lunga):
MimeBodyPart mainBody = new MimeBodyPart(); mainBody.setContent(testoMessaggio, "text/html"); |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 21:18.



















