Link to home
Start Free TrialLog in
Avatar of epicdevelopers
epicdevelopersFlag for United States of America

asked on

Creating Page Breaks in Outlook 2007 HTML E-mails

Our software generates 100+ page e-mails in HTML format, separating each page using

<div style="page-break-after: always;">&nbsp;</div>

This is so when printed, each page breaks exactly where we expect it to (we are generating invoices).

If the entire document is e-mailed to a computer using Outlook 2003, and then sent to a printer, everything prints as expected.

If the entire document is e-mailed to a computer using Outlook 2007, and then sent to a printer, it ignores our page break commands.

I realize Outlook 2007 uses a different HTML rendering engine -- my question is what is the work around?  What can we replace <div style="page-break-after: always;">&nbsp;</div> with so it generates a page break command upon printing, preferably a solution that works in both Outlook 2003 and Outlook 2007?

Thanks,
Avatar of epicdevelopers
epicdevelopers
Flag of United States of America image

ASKER

I'm no HTML or CSS guru.  I just struggle along looking up what I need.  What strikes me peculiar is that you are using a page break attribute in a DIV element which contains nothing but a non-breaking space.  That is, this isn't the DIV that encompasses the content for which you want to ensure a page break (i.e., the portion of the invoice after which you want a page break).  My guess is you have a bunch of content for part of the invoice and expect this separate element to do a page break on a prior element.  Is the invoice part after which you want a page break contained in its own DIV (was that what you meant by the non-breaking space)?  That is, is the DIV defining the invoice part the one that has the style attribute for page break?

The way that I've seen page breaks handled is with CSS definitions, not with div attributes, as described here:

http://www.htmlgoodies.com/beyond/css/article.php/3470341/CSS-and-Printing.htm

Another way that doesn't use the CSS class definition is similar to how you tried to use the style attribute, as decribed at:

http://www.chami.com/tips/internet/052898I.html

And lastly here is the definition as presented by W3 Schools which uses the CSS class to modify an element so a page break becomes inate to that element whether it was for an H2, HR, table, or other element:

http://www.w3schools.com/CSS/pr_print_pageba.asp

The above is what works in HTML in the supported *web browsers*.  Microsoft screwed every one of its customers when it pulled a fast one by switching from using IE's libraries to render HTML to instead using Word which is known to be a crappy HTML renderer.  So what works in HTML for web browsers may not work in MS Word's rendering.  This is one reason why I never bothered to, ahem, "upgrade" from OL2003.  I'm not interesting in using Word to render HTML during composition or display of an e-mail.  Some deficiencies of using Word are noted here (don't know if Word 2010 resolved any of them):

http://blogs.sitepoint.com/2007/01/10/microsoft-breaks-html-email-rendering-in-outlook/

Yet when I looked at http://msdn.microsoft.com/en-us/library/aa338201.aspx, it seems the page-break-after value for the style attribute in a DIV tag should be supported.  Well, should doesn't mean does.  There do appear to be values supported by the Word engine that may not be supported in web browsers.  See if using a P (paragraph) or HR (horizontal rule) with the STYLE attribute for page break works, or put the STYLE with page break in a DIV that encompasses the section of the invoice after which you want a page break, not in a following DIV.


I'm not a Word guru and asking them might find a solution (you didn't include the Word zone in your query).  There might be some Word-specific directive you can add as meta data to the HTML document that Word would recognize as a page break.  I've seen the HTML output generated when using Word as a poor substitute for an HTML editor and noticed that lots of directives get inserted that have meaning only to Word.  If the Word folks can't help, you may have to resolve to storing the invoices on a file server and providing a link to them in your e-mails.  Then recipients would click on the link and render the invoice in a web browser rather than using Word's crappy rendering.  If you don't like the idea of separating the e-mail from its intended content (by having a link to a separate document) then attach the invoice as a .doc file where within you can define the page breaks that you want.

2007 Office System Tool: Outlook HTML and CSS Validator
http://www.microsoft.com/downloads/en/details.aspx?familyid=0b764c08-0f86-431e-8bd5-ef0e9ce26a3a&displaylang=en

I've never used this and would be interested to know if it suggests changes to your HTML to make it better, resolve problems, or suggest changes to how you tried to add page breaks.  Personally I find it safest to use simple HTML for e-mail content because different e-mail clients have different problems rendering more complicated HTML.  Instead I attach the document and let the recipient handle how to render it (i.e., they will need Office or a viewer app for the doc, xls, ppt, and other Office-type files).
Thanks for your efforts but unfortunately I could not get these to work either.  I wrapped our actual content with P (rather than a nbsp all by itself) and tried 3 methods of setting the page break as suggested above -- all of the methods worked in 2003 and none of the methods worked in 2007.

I installed the validation tool and have not had much luck with it.  Bugs me that not only do you need to install it but they make you muck around in your registry with quite a few keys too.  Selected "Word 2007" as my validator in Visual Studio 2008 and it's telling me: Element 'html' is not supported.  Same with head, title, body, p, etc... obviously not behaving as I would expect it to.
ASKER CERTIFIED SOLUTION
Avatar of Vanguard_LH
Vanguard_LH
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial