commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott <sc...@minutestopost.com>
Subject Re: [email] html email with attachments - update
Date Fri, 20 Aug 2004 22:48:56 GMT
Hi,

Martin Cooper wrote:
> On Fri, 20 Aug 2004 16:04:12 -0400, Scott <scott@minutestopost.com> 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("me@mydomain.com");
>>email.addTo("you@yourdomain.com");
>>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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message