You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Lenny Primak <lp...@hope.nyc.ny.us> on 2011/12/14 22:17:05 UTC

Generating HTML email content with Tapestry?

I saw tapx-templatong project by doing a google search. Is this the way to do this?
Is it compatible with Tapestry 5.3?  I tried tapx-datefirld some time ago but it didn't work. 
Any suggestions/recommendations?  

Thanks. 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Generating HTML email content with Tapestry?

Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
The more I think about it the more I like this approach. I'll go with it as my #1 and only method. Thanks. 

On Dec 14, 2011, at 6:15 PM, Norman Franke <no...@myasd.com> wrote:

> That's what I do, and it works fine. Make an HTTP request to render the page and include that HTML in the email. Seems a bit unclean, but it does work. One does have to be careful about session state, though. Sending a request from the server to itself will not preserve the user's session without some extra work.
> 
> Norman Franke
> Answering Service for Directors, Inc.
> www.myasd.com
> 
> 
> 
> On Dec 14, 2011, at 4:58 PM, trsvax wrote:
> 
>> I would just build a Tapestry page and call it like a web service from your
>> email code and put what it returns in the email. It should not be any more
>> complicated than that. If you want it to say
>> 
>> Dear Barry
>> 
>> then make the url /email?dear=Barry
>> 
>> and the tml
>> 
>> Dear ${dear}
>> 
>> --
>> View this message in context: http://tapestry.1045711.n5.nabble.com/Generating-HTML-email-content-with-Tapestry-tp5075717p5075807.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>> 
>> ---------------------------------------------------------------------
>> 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: Generating HTML email content with Tapestry?

Posted by Greg Pagendam-Turner <gr...@liftyourgame.com>.

Here's some code I use to cleanup the html before I send it and to 
generate an unsubscribe link. I also remove the /assets stuff from my 
images since that breaks the images when the web server is restarted. 
Html emails tend to hang around longer than web pages.


     String cleanupHtml(String s, String url, User user) {
         String html = s;
         String safeEmail = user.getEmail().replace("@", "\\$0040");

         html = regexpReplace(html, "<head>", "<head>\n <BASE HREF=\"" + 
url + "\" />");
         html = regexpReplace(html, "/assets/ctx/[0-9a-f]+", "");
         html = regexpReplace(html, "/assets/[0-9a-f]+/ctx", "");
         html = regexpReplace(html, "<SCRIPT.*?>.*?</SCRIPT>", "");
         html = regexpReplace(html, "href=\"javascript:[^\"]*\"", 
"href='" + url + "'");
         html = regexpReplace(html, "href='javascript:[^']*'", "href='" 
+ url + "'");
         //clear any event handlers like 'onload'
         // commented these out because it was messing with meta tags
         //html = regexpReplace(html, "on[a-zA-Z]+ *= *\"[^\"]*\"", "");
         //html = regexpReplace(html, " on[a-zA-Z]+ *= *'[^']*'", "");
         //@import url(elements.css);
         //html = regexpReplace(html, "screen.css", "presentation.css");
         html = regexpReplace(html, "href=\"/liftyourgame/", "href=\"" + 
url);
         html = regexpReplace(html, "href=\"\\./", "href=\"" + url);
         html = regexpReplace(html, "src=\"\\./", "src=\"" + url);
         html = regexpReplace(html, "src=\"/liftyourgame/", "src=\"" + url);
         html = regexpReplace(html, "</html>.*", "</html>");
         html = regexpReplace(html, "\\[if IE][^\\[]*\\[endif]", "");

         html = regexpReplace(html, "</div> <!-- footer -->", "<br/>You 
are subscribed as <b>" + user.getEmail() + "</b> <a href='" + url + 
"unsubscribe/" + safeEmail + "'>Unsubscribe</a></div> <!-- footer -->");

         html = regexpReplace(html, "<!--[^-]*-->", "");

         return html;
     }


Regards,

Greg.

On 15/12/11 09:15, Norman Franke wrote:
> That's what I do, and it works fine. Make an HTTP request to render 
> the page and include that HTML in the email. Seems a bit unclean, but 
> it does work. One does have to be careful about session state, though. 
> Sending a request from the server to itself will not preserve the 
> user's session without some extra work.
>
> Norman Franke
> Answering Service for Directors, Inc.
> www.myasd.com
>
>
>
> On Dec 14, 2011, at 4:58 PM, trsvax wrote:
>
>> I would just build a Tapestry page and call it like a web service 
>> from your
>> email code and put what it returns in the email. It should not be any 
>> more
>> complicated than that. If you want it to say
>>
>> Dear Barry
>>
>> then make the url /email?dear=Barry
>>
>> and the tml
>>
>> Dear ${dear}
>>
>> -- 
>> View this message in context: 
>> http://tapestry.1045711.n5.nabble.com/Generating-HTML-email-content-with-Tapestry-tp5075717p5075807.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> 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: Generating HTML email content with Tapestry?

Posted by Norman Franke <no...@myasd.com>.
That's what I do, and it works fine. Make an HTTP request to render  
the page and include that HTML in the email. Seems a bit unclean, but  
it does work. One does have to be careful about session state, though.  
Sending a request from the server to itself will not preserve the  
user's session without some extra work.

Norman Franke
Answering Service for Directors, Inc.
www.myasd.com



On Dec 14, 2011, at 4:58 PM, trsvax wrote:

> I would just build a Tapestry page and call it like a web service  
> from your
> email code and put what it returns in the email. It should not be  
> any more
> complicated than that. If you want it to say
>
> Dear Barry
>
> then make the url /email?dear=Barry
>
> and the tml
>
> Dear ${dear}
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Generating-HTML-email-content-with-Tapestry-tp5075717p5075807.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


Re: Generating HTML email content with Tapestry?

Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
Interesting idea!  Seems kind of perverse though but it should work. Will put this as #2 idea with #1 TBD. 
Thanks. 



On Dec 14, 2011, at 4:58 PM, trsvax <tr...@gmail.com> wrote:

> I would just build a Tapestry page and call it like a web service from your
> email code and put what it returns in the email. It should not be any more
> complicated than that. If you want it to say
> 
> Dear Barry
> 
> then make the url /email?dear=Barry
> 
> and the tml
> 
> Dear ${dear}
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Generating-HTML-email-content-with-Tapestry-tp5075717p5075807.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> 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: Generating HTML email content with Tapestry?

Posted by trsvax <tr...@gmail.com>.
I would just build a Tapestry page and call it like a web service from your
email code and put what it returns in the email. It should not be any more
complicated than that. If you want it to say

Dear Barry

then make the url /email?dear=Barry

and the tml

Dear ${dear}

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Generating-HTML-email-content-with-Tapestry-tp5075717p5075807.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org