why does this html not get correctly rendered on IOS but not Android? (launched by mobile app)

StackOverflow https://stackoverflow.com/questions/22711808

Pergunta

I am generating an email from a mobile app that can be run on IOS or Android. Why does the "create email" dialogue on the device which is trigger have the body correctly html formatted for IOS but on my Nexus 7 device (in gmail) the HTML is not formatted (i.e. there is no table rendered, just the text).

HTML:

   <head>
   </head>
   <body>
   <table border="1">
   <tbody>
   <tr>
   <th>Table header</th>
   <th>Table header</th>
   </tr>
   <tr>
   <td>Table cell 1</td>
   <td>Table cell 2</td>
   </tr>
   <tr>
   <td>Table cell 3</td>
   <td>Table cell 4</td>
   </tr>
   </tbody>
   </table>
   </body>
   </html>

Background: Code is Corona SDK code, and is below.

local centerX = display.contentCenterX
local centerY = display.contentCenterY
local _W = display.contentWidth
local _H = display.contentHeight


-- Require the widget library
local widget = require( "widget" )
local emailImage = display.newImage( "email.png", centerX, 156 )


local function onSendEmail( event )
    local options =
    {
       to = { },
       cc = { },
       subject = "Test",
       isBodyHtml = true,
       body = [[
           <html>
           <head>
           </head>
           <body>
           <table border="1">
           <tbody>
           <tr>
           <th>Table header</th>
           <th>Table header</th>
           </tr>
           <tr>
           <td>Table cell 1</td>
           <td>Table cell 2</td>
           </tr>
           <tr>
           <td>Table cell 3</td>
           <td>Table cell 4</td>
           </tr>
           </tbody>
           </table>
           </body>
           </html>
       ]],
    }
    local result = native.showPopup("mail", options)
end


local sendEmail = widget.newButton
{
    left = 0, 
    top = 0,
    width = 298,
    height = 56,
    label = "Compose Email",
    onRelease = onSendEmail
}


-- center horizontally on the screen
sendEmail.x = centerX
sendEmail.y = _H - 156

API: http://docs.coronalabs.com/daily/api/library/native/showPopup.html

PS. I should not on IOS where it works it is the Apple email client that is triggered and holds the draft email. On Android it is the Gmail app that is triggered and holds the incorrectly formatted email

Foi útil?

Solução 3

Seems like the table tag is not be supported Use Table tag in Android Email

Perhaps just load as a HTML file attachment I guess.

Outras dicas

I send a ton of emails with table tags in the mobile version and they render fine in every mobile client.

Android GMail is weird though in that it's very specific. You need a width on your table tag, and on your widest table or element you need to set style="min-width:XXXpx;" on that.

You may not see it 'laying out' correctly because gmail mobile is using its 'auto-resize feature' to fit to your viewport, hence the needed min-width styling.

as John said those TH tags may be an issue as well.

It could be that the table is rendering, just your borders are not. try adding style="border:1px solid #000000;" to the outer table. It might help to add awidth=""` value there also.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top