Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Benjamin Nuttin
Giga Expert

Ran across a *very* old article that was quite helpful in solving my issue, so decided to share the knowledge. The crux of my conundrum was: how do I create an email notification that has a max-width so it doesn't expand all the way when someone views it in a wide screen (I find this affects readability) BUT that still shows fine in mobile email clients. Outlook is notoriously fickle with how it interprets CSS, so this required using tables.

The key is here: https://stackoverflow.com/questions/2426072/is-there-an-equivalent-of-css-max-width-that-works-in-ht...

Basically, you create a table with a width of 100%, and then within it, a row with two columns, and set the width attribute of one of the columns to the max width you're looking for.

The result can be found here: http://jsfiddle.net/48d1yh9j/

Note that you can set a mail script to template.print your 'header', one for the footer, and then in your notifications you can just focus on the content.

<!-- Start 'header' -->
<style>
p, table, div, hr{ font-family: Calibri, Arial; color: #002F6C; font-size:11pt}
table{ border-collapse:collapse;}
td{ text-align:left; vertical-align: top; padding:6px 10px; border: 1px solid silver;}
div hr{ color: silver; height:1px;} 
a:link{ color: navy}
a:visited{ color: navy}
</style>
<table cellspacing="0" width="100%">
    <tr>
        <td width="600" style='font-family: Arial; font-size: 14pt; color: white; background-color: navy; padding:8px; border: 2px solid navy'>ACME Service Portal</td>
        <td style="border:none"></td>
    </tr>
    <tr>
        <td width="600" style="border:2px solid navy; padding:10px">
<!-- End 'header' -->

            <p>
                Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
            </p>
            <table>
                <tr>
                    <td><b>Item 1</b></td>
                    <td>Hello</td>
                </tr>
                <tr>
                    <td><b>Item 1</b></td>
                    <td>World</td>
                </tr>
            </table>
            <p>
                Thank you
            </p>
<!-- Start 'footer' -->
        </td>
        <td style="border:none"></td>
    </tr>
    <tr>
        <td width="600" style="font-size:12px; border:none; padding:4px 0">If you require immediate assistance or have additional questions please call the Help Desk</td>
        <td style="border:none"></td>
    </tr>
</table>
<!-- End 'footer' -->

find_real_file.png

 

Comments
Carolina Loro
Tera Explorer

Hello there, Benjamin!!



Thanks a lot for the article! May I ask you if by any chance you found a way to preview the mobile version inside the ServiceNow backend outbox? Do you know if that's possible?

Because, everytime I inspect the page and try to simulate an Iphone using chrome it shows the whole page, not just the email preview pop-up.

 

Thanks!! 🙂

Version history
Last update:
‎11-15-2019 10:39 AM
Updated by: