Kan noget som dette her bruges:
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
public class SendMultipartEmail {
public static void main(String[] args) {
sendMultipartEmail();
}
public static void sendMultipartEmail() {
try {
Properties props = System.getProperties();
props.put("mail.smtp.host", "192.168.1.10");
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress("xx@somewhere.dk"));
message.addRecipient(Message.RecipientType.TO, new InternetAddress("xx@somewhere.dk"));
message.setSubject("Test");
MimeBodyPart mpart1 = new MimeBodyPart();
mpart1.setText("Linie 1\n" +
"Linie 2");
MimeBodyPart mpart2 = new MimeBodyPart();
mpart2.setContent("<H1>Overskrift</H1>\n" +
"Billede:\n" +
"<IMG SRC='
http://www.eksperten.dk/img/eksperten_logo_new.gif'>",
"text/html");
MimeMultipart mpart = new MimeMultipart();
mpart.addBodyPart(mpart1);
mpart.addBodyPart(mpart2);
message.setContent(mpart);
Transport.send(message);
} catch (AddressException e) {
} catch (MessagingException e) {
}
}
}
?
Umiddelbart ville jeg tro, at en ikke HTML capable mail klient vil
vise text med et attachement, og at en HTML capable klient vil vise
både text og HTML.
[ser OK ud i Netscape 7]
Det går naturligvis totalt i ged i en ikke MIME capable mail klient, men
det er der nok ikke noget at gøre ved.