Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Emails: fallback for mso conditional?

If you're like me, your eye will be twitching by the end of reading this. I don't blame you.

Our client has requested us to develop a responsive HTML email template, with two specifications:

  1. Using as few images as possible
  2. Using as many "fancy css-enabled features" as possible. Mostly, this just means rounded corners on boxes.

This question is specifically about executing the rounded corners. Gmail and Apple support CSS rounded corners, and Outlook requires vector graphics. For the remaining platforms, they're ok with using square edges.

Here's how we're detecting and executing outlook:

<!--[if mso]><v:shape>...</v:shape><![endif]--> 

Works like a charm, even back to Outlook 2000. The problem is, I can't figure out how to create a fallback. Intuition says this:

<!--[if !mso]>...<![endif]--> 

but it just gets ignored outright as a comment by most other email clients, and then corners are missing from the boxes altogether. I ask you, fine members of the SO community: is it possible to deploy markup for all platforms except MSO? Perhaps there's a more clever way to accomplish this that I haven't considered? Or is email HTML still too stone-age to attempt something like this?

like image 483
CodeMoose Avatar asked Aug 15 '13 14:08

CodeMoose


People also ask

What is MSO in HTML?

Basic syntax Section titled Basic syntax. We can use MSO (Microsoft Office) tags to add HTML / CSS anywhere in an email template. This code will be ignored by other email clients.

Does margin work in email HTML?

While margin is a CSS property, <cellpadding> is an HTML attribute. You cannot override it with the help of any CSS media queries. Therefore, you will not be able to make the emails mobile responsive.

Does Outlook support HTML emails?

The Outlook email client does not natively provide the option to create HTML emails. However, the email client does offer the option to insert HTML code into the message body and render the code into visual content that can be emailed to your Office 365 Group or Google Group.


1 Answers

Found a solution after much brain-wracking. Instead of this:

<!--[if mso]><v:shape>...</v:shape><![endif]--> <!--[if !mso]>[fallback goes here]<![endif]--> 

This works very well:

<!--[if mso]>     <v:shape>...</v:shape>     <div style="width:0px; height:0px; overflow:hidden; display:none; visibility:hidden; mso-hide:all;"> <![endif]-->      [fallback goes here]  <!--[if mso]></div><![endif]--> 

All it does is wrap the fallback in an invisible div in MSO, and deploys the vector solution instead.

Hope this helps someone in the future!

like image 104
CodeMoose Avatar answered Sep 22 '22 09:09

CodeMoose