2

I guess it is first time I see Yahoo mail doing some thing with flying colors and Gmail failing at it. I must be missing some thing.

I used ant mail task for automated delivery of test report -

<target name="sendtestreport">
    <tstamp>
        <format property="current.time" pattern="MM/dd/yyyy hh:mm" />
    </tstamp>
    <property name="subject" value="Selenium Test Report: " />

    <mail mailhost="test.de" mailport="25" subject="${subject} ${current.time}" 
        user="seleniumtests@test.de" password="password" messagemimetype="text/html">
        <from address="seleniumtests@test.com" />
        <replyto address="test@gmail.com" />
        <to address="test@gmail.com" />     
        <message src="${basedir}\test-output\emailable-report.html">If you have trouble viewing the message then open attachment</message>
        <attachments>
            <fileset dir="${basedir}">
                <include name="**/emailable-report.html"/>
            </fileset>
        </attachments>
    </mail>
</target>

Here in I am sending emailable test report which is generated by TestNG in body (as well as attachment) of mail. In my Gmail account message is badly mis formatted, no colors are displayed, text is overlapping and misaligned. While in Yahoo mail it appears perfect.

Is there any setting I need to modify in Gmail to have message displayed in right format. Or is it defective behavior of Gmail?

Tarun
  • 3,456
  • 10
  • 48
  • 82

1 Answers1

6

Each e-mail client chooses how it renders HTML e-mails. Several web-based clients need to strip out CSS so you don't hijack the look of the site. There is a minimal set of CSS selectors and HTML tags that each e-mail client chooses to allow. You probably need to make some major modifications to the emailable-report.html template so that it behaves for Gmail.

There are entire businesses built on their skills of creating cross-client e-mail templates; it might take you quite a bit of time and research to make one that works for Gmail (as well as all the other major clients).

Here are a few resources to get you started:

And a million others if you poke around on Google some more.

Community
  • 1
  • 1
Cᴏʀʏ
  • 105,112
  • 20
  • 162
  • 194
  • guess what, I am just using TestNG and it generated the report emailable-report.html I really don't think it is feasible for me to update it. And even if I do then I need to keep it in sync with all future releases of TestNG – Tarun Nov 29 '11 at 19:52
  • 2
    @Tarun: The issue lies entirely within the e-mail template. You may have to take on the task of maintaining the e-mail template if you'd like it to look good in other e-mail clients. – Cᴏʀʏ Nov 29 '11 at 19:56