Hi,

Martin Cooper wrote:
On Fri, 20 Aug 2004 16:04:12 -0400, Scott <[EMAIL PROTECTED]> wrote:

Hi,

Attached is an updated (somewhat quick-and-dirty) patch for
MultiPartEmail.java (the previous one had problems :)). It allows you do
to something like:

MultiPartEmail email = new MultiPartEmail();
email.setFrom("[EMAIL PROTECTED]");
email.addTo("[EMAIL PROTECTED]");
email.setSubject("message subject");
email.setSubType("mixed");

MimeMultipart multiPart = new MimeMultipart("alternative");

// text alternative
MimeBodyPart bodyPart1 = new MimeBodyPart();
bodyPart1.setContent("Text message", "text/plain");
multiPart.addBodyPart(bodyPart1);

// html alternative
MimeBodyPart bodyPart2 = new MimeBodyPart();
bodyPart2.setContent("<html><body><p>html message</p></body></html>",
"text/html");
multiPart.addBodyPart(bodyPart2);

email.addPart(multiPart);

// add attachments if you'd like, then
email.send()


No doubt I'm missing something obvious here, but why would you want to
construct a message like the one above? Unless I'm mistaken, what the
above code creates is a message structured like:

    multipart/mixed
        multipart/alternate
            text/plain
            text/html

Now I understand the alternate with text and HTML, by why are you
wrapping this in another multipart (which only has one part!) of type
mixed?


Yes, the above example doesn't make sense unless you're adding attachments. What I'd like is:
multipart/mixed
multipart/alternative
text/plain
text/html
application/pdf
etc.


The current MultiPartEmail doesn't allow you to do this, and the HtmlEmail class won't do the job either (plain text alternatives do not work properly with HtmlEmail). To be honest, I'd prefer to rewrite larger parts of both classes (wouldn't actually be a lot of work to get everything sorted out, I don't think) than use the patch, but thought I'd start somewhere :).

Scott

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to