PScribo icon indicating copy to clipboard operation
PScribo copied to clipboard

HTML rendering in Outlook not the same as in web browsers

Open janegilring opened this issue 10 years ago • 10 comments

When sending HTML-reports via e-mail, the HTML is not rendered the same way in Outlook as a web browser.

Here is an example: $html = Get-Content '~\Desktop\PScribo Demo 1.html' Send-MailMessage -To [email protected] -From [email protected] -SmtpServer smtp.domain.com -Subject Test-report -BodyAsHtml -Body ($html | Out-String)

In the below image, e-mail content from Outlook is on the left while the same HTML-file viewed in a web browser is on the right side:

example

janegilring avatar Oct 02 '15 10:10 janegilring

Outlook use Word for viewing. blame Microsoft :)

McAndersDK avatar Oct 02 '15 11:10 McAndersDK

Just circling back around to this. I'm thinking of modifying the plugin architecture to make it easier to support different export options for each plugin. However, this should be (fairly) easy to implement. I'll just need to remove the outer <div> tag that provides the "page" look..

iainbrighton avatar Apr 18 '16 15:04 iainbrighton

@janegilring @McAndersDK Apologies for the delay :blush:. There is now a Export-Document -Path ~\Desktop -Format Html -Options @{ NoPageLayoutStyle = $true } supported for HTML output that should fix this. Version 0.7.8 has been pushed to the PowerShell Gallery! Enjoy :smiley:. Any problems let me know.

iainbrighton avatar May 25 '16 21:05 iainbrighton

not sure how this fix anything? :O) but the styling is just bad in outlook. and alwayse will as word is a bad HTML render. I would if I needed this to work in outlook, and have the same styling:

  • open word with the docx export (COM.object)
  • have word save it as HTML.
  • email the bloated html result.
  • profit

McAndersDK avatar May 26 '16 06:05 McAndersDK

@McAndersDK If you have Word installed then that's certainly an option!

The problem with the HTML outputting was the 'page look-and-feel' CSS causing Outlook issues. The -Options @{ NoPageLayoutStyle = $true } export option turns this functionality off CSS styling off when generating the HTML.

iainbrighton avatar May 26 '16 08:05 iainbrighton

I tried to add -Options @{ NoPageLayoutStyle = $true } to Export-Document when using the builtin Demo 2 for testing, but the issue seem to remain (Outlook 2016).

janegilring avatar May 27 '16 06:05 janegilring

@janegilring I'll need to check that out. Presumably there's something more fundamental in the styles (not) being rendered incorrectly by Outlook (grrr)

iainbrighton avatar May 27 '16 07:05 iainbrighton

OK - looks like I need to digest this to determine what's not being supported by Outlook. My gut feel is that this is probably due to lack of <div> and CSS support. There is a chance that this can't be easily fixed without breaking the existing HTML5 implementation..

iainbrighton avatar May 31 '16 12:05 iainbrighton

I just noticed that the rendering in the Outlook.com mobile app also is broken. I`m generating a table with 10 lines for a daily report, and only 3 of them is visible in the app. The same mails looks fine in Outlook on a PC. The whole e-mail content also looks very small in the app. Tested on 2 different Android phones.

janegilring avatar Dec 28 '18 08:12 janegilring

Any Update to support Save to HTML feature in Microsoft Word?

itadder avatar Nov 06 '19 13:11 itadder