Welcome to the first installment of my reviews of entries in the Best of ColdFusion 10 contest. If you attended cfObjective last week, then you know this ended up as a good news/bad news type situation. The number of entries were relatively low - 4. The quality of the entries though were high. Personally - I do these contests because I love to see what people build. It's fun. So no matter how many people find the time to participate, I consider it a net win for all of us. With that out of the way, let's look at our first entry, the HTML Email Utility by some dude named Ben Nadel.
If you've ever worked in HTML email, then you are well aware of the serious limitations imposed on you in regards to styling your content. HTML email is so limited it makes IE6 look like a sexy browser. One of the most critical things you can't do in HTML email is supply a style sheet. So instead of having a nice block of CSS declarations, you must use inline style sheets.
Ben's utility attempts to simplify this. You provide it "good" HTML (with a style sheet) and it rewrites it to make use of inline styles. This is done using the jsoup library I mentioned before. It makes use of ColdFusion 10's easy Java library loading to include the bits.
He also makes good use of closures within his processing code. Here's a random sample.
Overall - I think this is an incredibly practical application and something I can see using in the future. Want to try it? You can hit the Demo button below to run it on my server. You can also watch a demo video Ben created here and get the code from his Github repo here.
Archived Comments
Great job on this Ben, I actually remembered this the other day and used it to create a nice html email template. Took all of 3 minutes to download and get started... SUPER helpful.
I hate to go off topic, but it's my blog, so there...
Ben - your Gravatar is an arcade game. What game is that and is it yours?
Really nice work Ben! Now you just need to add in a LESS compiler and I'm sold!
Forgive me, but most email clients work perfectly well with a full stylesheet declared within a style tag in the head section. Outlook, Gmail, Hotmail, etc. I've been doing that for years sending millions of emails (non-spam of course). It's been well tested with not a single complaint. I'm wondering if I've missed the point here?
That's a cool bit of code by the way. (I still don't get closures) It's come a long way from the cfscript I knew from CF5!
I don't know man - as recently as about 8 months or so ago when I updated the email support for BlogCFC I had to make use of this technique. GMail didn't use any of my <style> block declarations.
I built a MAME cabinet a few years ago. It was originally a Street Fighter 2 cab. Had a ton of fun building it. Unfortunately I had to sell it when I moved to my current place. I'm going to be building another for my office sometime later this year.
Here's my 7 year old forum post about it: http://forum.arcadecontrols...
Ray, I'm wrong about Gmail. It does indeed ignore <style> tags. Blast. Maybe none of the recipients realised they were missing pretty formatting as it's perfectly readable without any. At least you've made me aware of this now!
I can't remember the name, but there IS a service out there that gives you mail previews of your mail for all the major services. I can't remember the name, but it looked like a super-useful service for testing stuff like this.
There are some email testing services around, but you probably mean Litmus http://www.litmus.com
or try http://litmus.com without www
That was it - thanks.
Ooh, gold! Thanks Thilo and Ray. Litmus even shows previews on 8 different mobile clients. This is so clever! Love it. Is it worth $50/month? If you can do all your testing in that time then yes, definately.
Litmus let me download 101 full size screen shots from countless email clients for free. The only clients that fail to support <style> tags are Gmail and Hotmail. I'm impressed that Yahoo worked well and even an ancient version of Lotus Notes (6). Blackberry, Win Phone 7, Win Mob 6, Symbian 6, iphone 3, all good.
So it's just Hotmail and Gmail that are the big let downs. Booo!