Inline-Bilder in E-Mails mit JavaMail

Ich möchte eine E-Mail mit einem Inline-Bild mit Javamail senden.

Ich mache so etwas.

MimeMultipart content = new MimeMultipart("related");

BodyPart bodyPart = new MimeBodyPart();
bodyPart.setContent(message, "text/html; charset=ISO-8859-1");
content.addBodyPart(bodyPart);

bodyPart = new MimeBodyPart();
DataSource ds = new ByteArrayDataSource(image, "image/jpeg");
bodyPart.setDataHandler(new DataHandler(ds));
bodyPart.setHeader("Content-Type", "image/jpeg; name=image.jpg");
bodyPart.setHeader("Content-ID", "<image>");
bodyPart.setHeader("Content-Disposition", "inline");
content.addBodyPart(bodyPart);

msg.setContent(content);

Ich habe es auch versucht

    bodyPart.setHeader("inline; filename=image.jpg");

un

    bodyPart.setDisposition("inline");

aber egal was passiert, das Bild wird als Anhang gesendet und die Content-Dispostion verwandelt sich in "Anhang".

Wie sende ich mit javamail ein Bild inline in der E-Mail?

Antworten auf die Frage(14)

Ihre Antwort auf die Frage