Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html email with background-image style not shown

I am creating an email template which has to display images from external website. I had placed some <img> tags for rendering the images and there are some <td> tags with background-image property set in inline css of the elements.

Now, when an email is received in outlook, the images are not displayed (this is expected as the images are not embedded). And I click the download images to see the images properly. The images in <IMG> tag are only shown and the background-image for the <TD> is not rendered.

Any views on solving this problem?

Thanks!

like image 779
Chaitanya Avatar asked Jan 14 '11 10:01

Chaitanya


People also ask

Why is my background image not showing in HTML?

Make sure the image path is set correctly in the background-image url. Once you have made sure that your CSS file is linked correctly, also check that the image itself is set correctly. Again, you will want to open your code inspector in the browser to check.

Why are images not showing in HTML email?

In some cases, senders may be able to know whether an individual has opened a message with unique image links. As always, Gmail scans every message for suspicious content and if Gmail considers a sender or message potentially suspicious, images won't be displayed and you'll be asked whether you want to see the images.

Can I use background image in HTML email?

You can add background images—with no coding required! To try it for yourself, sign up now for free. If you have an existing HTML email template, Campaign Monitor's “Bulletproof Background Images” has the code snippets you need to create email body background images.


1 Answers

There is a way of displaying HTML images.

Right html emails rendered as MSWord document in outlook.

I got the solution from this https://stackoverflow.com/a/12693917/413032 post.

So we need an alternate.

In fact you may open your html email in MSWORD and finding what seems wrong and considering what can be an alternate gives idea.

Here is what I did ;

  1. Added v namespace to html tag

      < html xmlns:v="urn:schemas-microsoft-com:vml"
    
  2. Added v's style to head block

    < head >
     <style type="”text/css”">
           v\:* { behavior: url(#default#VML); display:inline-block}
     </style>
    
  3. In table or where you need add your MSWord alternate

    <table style="background-image: url('https://e-telesaglik.com/images/email/canvas-bg.jpg');background-repeat:no-repeat;" cellpadding="0" width="960">
                <!--[if gte vml 1]>
                        <v:shape 
                            stroked='f'
                             style='position:absolute;margin-left:-90pt;margin-top:-1.55pt;     
                                    z-index:-503306481;
                                    visibility:visible;
                                    width:720pt;
                                    height:475pt;           
                                    top:0;
                                    left:0;
                                    border:0;                                               
                                    '>
                            <v:imagedata src="https://e-telesaglik.com/images/email/canvas-bg.jpg"/>
                        </v:shape>
                <![endif]-->
                    <tbody> ....
    

That is all. Sure it will be a MSWord render. And more, as you notice we use absolute positioning...

Anyway this is a workaround and solves the issue in a way. We hope one day MS-Outlook renders html e-mails with a web browser not with MS-Word.

like image 137
Davut Gürbüz Avatar answered Dec 29 '22 18:12

Davut Gürbüz