You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Richard Hill <ri...@su3analytics.com> on 2011/04/15 16:48:46 UTC
MailMessagePreparer - embedding images (howardlewisship.tapx)
Hi,
We're using MailMessagePreparer to add a RenderedStream to
javax.mail.Message.
It works great, our page is being appended to the Message no problem.
However there are images in the page, and I need to get these embedded
in the message. At the moment this is what we're doing (semi-pseudo code
for brevity):
TemplateRenderer renderer =
templateAPI.createRenderer("SummaryEmailTemplate", "en", "default");
RenderedStream renderedStream = renderer.render();
Message message = new MimeMessage(session);
message.setFrom();
// ... add recipients etc ...
MailMessagePreparer.prepareMessage(message, renderedStream);
Transport.send(message);
To add images I need to construct a multi-part message, where I add
content to each MimeBodyPart (html to one part, images to the other).
The prepareMessage() method only takes a Message as arg, not a
MimeBodyPart, so I am not sure how to go about constructing my message
using prepareMessage() to add the html part, distinct from the images
part.
Any advice on how to construct a multi-part message with images?
Thanks Richard.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: MailMessagePreparer - embedding images (howardlewisship.tapx)
Posted by Richard Hill <ri...@su3analytics.com>.
> <img src="${asset:image.jpg}"
>
> It's funny ... the client I wrote this code for didn't actually want
> the multi-part message portion; I wrote it thinking they did, THEN
> they clarified their system, which relies on a content delivery
> network. Glad it was of use!
Yes it was thanks. Constructing multipart messages is a bit of pain, this makes it a breeze.
A great tool for anyone in the Tapestry or wider java dev community who needs to generate
templated emails.
Cheers
On Fri, 2011-04-15 at 10:29 -0700, Howard Lewis Ship wrote:
> On Fri, Apr 15, 2011 at 8:36 AM, Richard Hill <ri...@su3analytics.com> wrote:
> > Ok got it sorted. The solution is very simple, in your template you just
> > do:
> >
> > <img src="${asset:image.jpg}"
>
> It's funny ... the client I wrote this code for didn't actually want
> the multi-part message portion; I wrote it thinking they did, THEN
> they clarified their system, which relies on a content delivery
> network. Glad it was of use!
>
> >
> > and MailMessagePreparer automatically constructs a multi-part message.
> >
> > V useful!
> >
> >
> >
> >
> > On Fri, 2011-04-15 at 15:48 +0100, Richard Hill wrote:
> >> Hi,
> >>
> >> We're using MailMessagePreparer to add a RenderedStream to
> >> javax.mail.Message.
> >>
> >> It works great, our page is being appended to the Message no problem.
> >> However there are images in the page, and I need to get these embedded
> >> in the message. At the moment this is what we're doing (semi-pseudo code
> >> for brevity):
> >>
> >> TemplateRenderer renderer =
> >> templateAPI.createRenderer("SummaryEmailTemplate", "en", "default");
> >> RenderedStream renderedStream = renderer.render();
> >>
> >> Message message = new MimeMessage(session);
> >>
> >> message.setFrom();
> >> // ... add recipients etc ...
> >>
> >> MailMessagePreparer.prepareMessage(message, renderedStream);
> >>
> >> Transport.send(message);
> >>
> >> To add images I need to construct a multi-part message, where I add
> >> content to each MimeBodyPart (html to one part, images to the other).
> >> The prepareMessage() method only takes a Message as arg, not a
> >> MimeBodyPart, so I am not sure how to go about constructing my message
> >> using prepareMessage() to add the html part, distinct from the images
> >> part.
> >>
> >> Any advice on how to construct a multi-part message with images?
> >>
> >> Thanks Richard.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: MailMessagePreparer - embedding images (howardlewisship.tapx)
Posted by Howard Lewis Ship <hl...@gmail.com>.
On Fri, Apr 15, 2011 at 8:36 AM, Richard Hill <ri...@su3analytics.com> wrote:
> Ok got it sorted. The solution is very simple, in your template you just
> do:
>
> <img src="${asset:image.jpg}"
It's funny ... the client I wrote this code for didn't actually want
the multi-part message portion; I wrote it thinking they did, THEN
they clarified their system, which relies on a content delivery
network. Glad it was of use!
>
> and MailMessagePreparer automatically constructs a multi-part message.
>
> V useful!
>
>
>
>
> On Fri, 2011-04-15 at 15:48 +0100, Richard Hill wrote:
>> Hi,
>>
>> We're using MailMessagePreparer to add a RenderedStream to
>> javax.mail.Message.
>>
>> It works great, our page is being appended to the Message no problem.
>> However there are images in the page, and I need to get these embedded
>> in the message. At the moment this is what we're doing (semi-pseudo code
>> for brevity):
>>
>> TemplateRenderer renderer =
>> templateAPI.createRenderer("SummaryEmailTemplate", "en", "default");
>> RenderedStream renderedStream = renderer.render();
>>
>> Message message = new MimeMessage(session);
>>
>> message.setFrom();
>> // ... add recipients etc ...
>>
>> MailMessagePreparer.prepareMessage(message, renderedStream);
>>
>> Transport.send(message);
>>
>> To add images I need to construct a multi-part message, where I add
>> content to each MimeBodyPart (html to one part, images to the other).
>> The prepareMessage() method only takes a Message as arg, not a
>> MimeBodyPart, so I am not sure how to go about constructing my message
>> using prepareMessage() to add the html part, distinct from the images
>> part.
>>
>> Any advice on how to construct a multi-part message with images?
>>
>> Thanks Richard.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Howard M. Lewis Ship
Creator of Apache Tapestry
The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!
(971) 678-5210
http://howardlewisship.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: MailMessagePreparer - embedding images (howardlewisship.tapx)
Posted by Richard Hill <ri...@su3analytics.com>.
Ok got it sorted. The solution is very simple, in your template you just
do:
<img src="${asset:image.jpg}"
and MailMessagePreparer automatically constructs a multi-part message.
V useful!
On Fri, 2011-04-15 at 15:48 +0100, Richard Hill wrote:
> Hi,
>
> We're using MailMessagePreparer to add a RenderedStream to
> javax.mail.Message.
>
> It works great, our page is being appended to the Message no problem.
> However there are images in the page, and I need to get these embedded
> in the message. At the moment this is what we're doing (semi-pseudo code
> for brevity):
>
> TemplateRenderer renderer =
> templateAPI.createRenderer("SummaryEmailTemplate", "en", "default");
> RenderedStream renderedStream = renderer.render();
>
> Message message = new MimeMessage(session);
>
> message.setFrom();
> // ... add recipients etc ...
>
> MailMessagePreparer.prepareMessage(message, renderedStream);
>
> Transport.send(message);
>
> To add images I need to construct a multi-part message, where I add
> content to each MimeBodyPart (html to one part, images to the other).
> The prepareMessage() method only takes a Message as arg, not a
> MimeBodyPart, so I am not sure how to go about constructing my message
> using prepareMessage() to add the html part, distinct from the images
> part.
>
> Any advice on how to construct a multi-part message with images?
>
> Thanks Richard.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org