Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional HTML (IF/ELSE) logic

I understand that in order to display outlook-specific HTML within an email I can implement code such as:

<!--[if (gte mso 9)|(IE)]>
Welcome to the newsletter.
<![endif]-->

However, how do I implement if/else logic. For example, without using CSS classes, I need to display one section of content in Outlook and a completely different section of content in other clients.

Is this possible?

(CSS Classes have proven to be unreliable hence my requirements for conditional HTML instead).

like image 695
Jordan Avatar asked Jul 22 '15 10:07

Jordan


1 Answers

The conditional coding IS actually the IF/ELSE statement. The issue is the ELSE part is not built in. To solve your issue, you need something to hide the content you no longer want MSO to use but show up in all other clients.

This can be handled either through conditional classes (in the if statement) OR, as you mentioned you did not want to use classes, you can use the mso-hide:all css that is only recognized by Microsoft office.

Found a great example of this for reference. Pulled from this post:

<!--[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]-->

This is a good reference on usage of mso-hide:all

like image 133
Gortonington Avatar answered Nov 04 '22 08:11

Gortonington